Skip to content

Instantly share code, notes, and snippets.

@wayneashleyberry
Created November 12, 2012 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayneashleyberry/4058663 to your computer and use it in GitHub Desktop.
Save wayneashleyberry/4058663 to your computer and use it in GitHub Desktop.
send sms via bulk sms api
<?php
function sendsms($number, $message)
{
$username = 'username';
$password = 'password';
//set POST variables
$url = 'http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0';
$fields = array(
'username' => urlencode($username),
'password' => urlencode($password),
'message' => urlencode($message),
'msisdn' => urlencode($number)
);
$fields_string = '';
//url-ify the data for the POST
foreach($fields as $key=>$value)
{
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment