Skip to content

Instantly share code, notes, and snippets.

@mikekoro
Created August 20, 2012 20:23
Show Gist options
  • Save mikekoro/3407519 to your computer and use it in GitHub Desktop.
Save mikekoro/3407519 to your computer and use it in GitHub Desktop.
OneAPI send SMS PHP class
<?php
Class SendSMS {
public $phone_number;
public function __construct($phone_number) {
$this->phone_number = $phone_number;
}
public function oneAPI() {
$url = "https://oneapi-gw.gsma.com/smssend/2_0/smsmessaging/outbound/tel%3A7511/requests"; // END POINT
$username = 'secret'; // APP's login
$password = 'secret'; // and psswd
$request = array(
'address' => $this->phone_number,
'message' => 'hello world',
'senderAddress' => 'tel:7511'
);
$request = http_build_query($request);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // hide output
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
// print_r($info);
}
}
$hello = new SendSMS('+1XXXXXXXXX'); // WHITE LISTED PHONE
$hello->oneAPI();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment