tags:

views:

206

answers:

1

Hello,

I have a question about the use off the http api from the company clickatell.

They actually have several api that you can use, amongst are xml and smtp also.

Does anyone have any experience with those, especially with the http api.

For the http api:

Does this php code actually doing the work in the background?

This line $ret = file($url); - I am sorry, I haven't setup anything yet to test it. I am just trying to find out wich api I can start testing with -.

Also, is there a performance difference between using smtp api and http api?

// SMS gateway script
    $user = "XXXX";
    $password = "XXXXXX";
    $api_id = "XXXXXX";
    $baseurl ="http://api.clickatell.com";
    $text = urlencode("HTTP://WWW.TIMES.COM/DOWNLOADS/SUGRAFREE.SISX");
    $to = $_POST["phone number"];
 // auth call
    $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
    // do auth call
    $ret = file($url);
    // split our response. return string is on first line of the data returned
    $sess = split(":",$ret[0]);
    if ($sess[0] == "OK") {
    $sess_id = trim($sess[1]); // remove any whitespace
    $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
    // do sendmsg call
    $ret = file($url);
    $send = split(":",$ret[0]);
    if ($send[0] == "ID")
    echo "An Email with account details and SMS has been sent..

thanks, Richard

+1  A: 

I have experience with clickatell API - a good one.

SMTP is slower - you need your email to get to the clickatell servers. which could take a second or a minute.

HTTP is much better and recommended, moreover you can create one session and send multiple sms in one go.

ps: i have not tested your code, but it should work, although i would recommend checking CURL library for HTTP connections.

dusoft
It's only to send confirmations at a designated time for each user. I guess that would be a seperate session id for each user or do you get the same session id back if the session is still open and you are doing the autharisation again?
Richard
What are the advantages off using curl? do you have an equivalent code line in curl instead off using $ret=file($url)
Richard
advantages are that you are not using file functions that were mostly workaround only for URLs, but using a proper CURL library.moreover, CURL enables you to do much more than just HTTP connections - checking only headers, redirections, anything.
dusoft
I think session is held for a definite time or unless ended from API user. Please, study the API docs, I haven't been developing for this API for a long time now.
dusoft