Я буду использовать Curl
Код: Выделить всё
curl -X POST \
'https://api.messente.com/v1/omnimessage' \
-u YOUR_MESSENTE_API_USERNAME:YOUR_MESSENTE_API_PASSWORD \
-H 'Content-Type: application/json' \
-d '{
"to": "",
"messages": [
{
"channel": "sms",
"sender": "",
"text": "hello sms"
}
]
}'
Код: Выделить всё
$url = 'https://api.messente.com/v1/omnimessage';
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$data = array (
"to" => "00353894215730",
"messages" => array("channel"=> "sms",
"sender"=> "00353894215730",
"text"=> "test message",
),
);
$post = http_build_query($data);
curl_setopt( $c, CURLOPT_POSTFIELDS, $post);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$AccountSid='xxxxx';
$AuthToken = 'xxxxx';
$auth = $AccountSid.':'.$AuthToken ;
curl_setopt( $c, CURLOPT_USERPWD, $auth ); // authenticate
$response = curl_exec ($c);
curl_close ($c);
Подробнее здесь: https://stackoverflow.com/questions/791 ... url-in-php