Skip to content

Instantly share code, notes, and snippets.

@rajankur
Last active August 29, 2015 14:14
Show Gist options
  • Save rajankur/d19b64a5eacc4ac08453 to your computer and use it in GitHub Desktop.
Save rajankur/d19b64a5eacc4ac08453 to your computer and use it in GitHub Desktop.
PHP: sendSMS via cURL
<?php
/**
* a function for sending sms using curl.
* @param integer $to -must be a valid 10 digit mobile number
* @param string $msg -must be valid message.
* @return string
*/
function sendSms($to,$msg)
{
$username = ""; // The username of SENDER.
$password = ""; // The password of SENDER.
$sendername = ""; // SENDER ID or SENDER NAME
$msg = urlencode($msg);
$url = "http://sms2.at54.com/reseller/sendsms.jsp?user=$username&password=$password&mobiles=$to&sms=$msg&senderid=$sendername"; // The API URL for cURL request, change it accordingly.
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
return $url;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment