phpsmsclickatell

Text multiple numbers using clickatell php gateway API


I am currently using clickatell to send a msg to a single numbers using the FOR method

for($i = 0;$i < count($textrecievers); $i++){
$url = 'http://api.clickatell.com/http/sendmsg?user=user&password=****&api_id=00000&to=1'.$textrecievers[$i].'&text='.$msgtxt.'&mo=1&from='.$_SESSION['routing'];

$ret = file($url);
            }

The problem with this is i cannot report it to the database if one of them fails since i cannot use this method

$send = explode(":",$ret[0]);

                if ($send[0] == "ID") {
echo 'OK';
}

Is there any way to just send it as a bulk text like this:

$to = array('1111111111','2222222222','3333333333')

and then put it in the usr as such

 $url = 'http://api.clickatell.com/http/sendmsg?user=user&password=****&api_id=00000&to='.$to.'&text='.$msgtxt.'&mo=1&from='.$_SESSION['routing'];

so it will send it to all the numbers in the array at 1 go, so i can report it as a success or not.


Solution

  • Not sure if I understand your question correctly, but you can comma separate mobile numbers like this:

    http://api.clickatell.com/http/sendmsg?api_id=....&to=123456789,123456789,123456789,123456789,123456789,123456789&text=....

    You can comma separate about 300 numbers with an HTTP GET to be safe (and much more with a POST such as 800 - depending on how long you wait to timeout).

    // Comma separate and add leading 1 for country code $comma_separated = implode(",1", $YourArray);

    You will receive a tracking message ID for each message (or an error), so you can keep track if any specific number was rejected.

    Does this answer your question?