0
I cannot use the script because of the Httprequest class I already downloaded several classes and always error: (https://dev.infobip.com/docs/fully-featured-textual-message)
$request = new HttpRequest();
$request->setUrl('https://api.infobip.com/sms/1/text/advanced');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'accept' => 'application/json',
'authorization' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==',
'content-type' => 'application/json'
));
$request->setBody('{
"bulkId":"BULK-ID-123-xyz",
"messages":[
{
"from":"InfoSMS",
"destinations":[
{
"to":"41793026727",
"messageId":"MESSAGE-ID-123-xyz"
},
{
"to":"41793026731"
}
],
"text":"Artık Ulusal Dil Tanımlayıcısı ile Türkçe karakterli smslerinizi rahatlıkla iletebilirsiniz.",
"flash":false,
"language":{
"languageCode":"TR"
},
"transliteration":"TURKISH",
"notifyUrl":"http://www.example.com/sms/advanced",
"notifyContentType":"application/json",
"callbackData":"DLR callback data",
"validityPeriod": 720
},
{
"from":"41793026700",
"destinations":[
{
"to":"41793026785"
}
],
"text":"A long time ago, in a galaxy far, far away... It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire.",
"sendAt":"2015-07-07T17:00:00.000+01:00"
}
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
So it worked All right thanks for Help MIGUEL the right code got:
<?php
$data_string = '{
"messages":[
{
"from":"InfoSMS",
"destinations":[
{
"to":"5517998652984"
}
],
"text":"O SMS chegou!",
"flash":true
}
]
}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.infobip.com/sms/1/text/advanced",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data_string,
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: Basic QnbcXX6735BYH==",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
What’s the mistake that comes?
– Miguel
Class Https No Found
– Gustavo Marcelo
What is the API URL, the one that sends the text, that’s what you want right? Send a text?
– Miguel
this send sms to url is:
– Gustavo Marcelo
http://api.infobip.com/tts/3/single
– Gustavo Marcelo
Have you tried their example? at the end of this page https://dev.infobip.com/docs/send-single-sms, at the bottom where it says "https://dev.infobip.com/docs/send-single-sms", in the request section there is a tab that has an example of php
– Miguel
tried but also uses error ai httpsrequest class
– Gustavo Marcelo