Created
April 4, 2013 13:30
-
-
Save pkdavies/5310347 to your computer and use it in GitHub Desktop.
Clickatell test API call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = "user"; | |
$password = "pass"; | |
$api_id = "123456"; | |
$baseurl ="http://api.clickatell.com"; | |
$text = urlencode("Knock knock); | |
$to = "+4471253789"; | |
// auth call | |
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id"; | |
// do auth call | |
$ret = file($url); | |
// explode our response. return string is on first line of the data returned | |
$sess = explode(":",$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 = explode(":",$ret[0]); | |
if ($send[0] == "ID") { | |
echo "successnmessage ID: ". $send[1]; | |
} else { | |
echo "send message failed"; | |
} | |
} else { | |
echo "Authentication failure: ". $ret[0]; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment