Skip to content

Instantly share code, notes, and snippets.

@samwize
Created October 23, 2012 07:49
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 samwize/3937512 to your computer and use it in GitHub Desktop.
Save samwize/3937512 to your computer and use it in GitHub Desktop.
Hoiio Example: Send an SMS
<?php
/* Hoiio developer credentials */
$hoiioAppId = "YOUR_APP_ID_HERE";
$hoiioAccessToken = "YOUR_ACCESS_TOKEN_HERE";
$sendSmsURL = "https://secure.hoiio.com/open/sms/send";
/* Recipient of SMS */
$destination = "+6511111111";
$message = "Congrats! You have just sent your first SMS with Hoiio!";
/* prepare HTTP POST variables */
$fields = array(
'app_id' => urlencode($hoiioAppId),
'access_token' => urlencode($hoiioAccessToken),
'dest' => urlencode($destination), // send SMS to this phone
'msg' => urlencode($message) // message content in SMS
);
// form up variables in the correct format for HTTP POST
$fields_string = "";
foreach($fields as $key => $value)
$fields_string .= $key . '=' . $value . '&';
$fields_string = rtrim($fields_string,'&');
/* initialize cURL */
$ch = curl_init();
/* set options for cURL */
curl_setopt($ch, CURLOPT_URL, $sendSmsURL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
/* execute HTTP POST request */
$result = curl_exec($ch);
print($result);
/* close connection */
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment