Reputation: 1297
I've looked for similar topics and could't find any solutions, I'm hoping someone can help me..
Note: I'm running the script on xampp localhost and my country code is +90 I've followed the Nexmo documentation to send an sms. and below is the php script.
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxxxxx',
'api_secret' => 'xxxxxxxxxxx',
'to' => 90542xxxxxxx,
'from' => 'MyCompanyName',
'text' => 'Working'
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
?>
and the following is the outcome. it seems like it is sending it however I'm not receiving a sms on my mobile what could possibly cause this?
{ "message-count": "1", "messages": [{ "to": "90542xxxxxxx", "message-id": "0C00000016FF36E9", "status": "0", "remaining-balance": "1.77080000", "message-price": "0.01910000", "network": "28602" }] }
Upvotes: 2
Views: 1425
Reputation: 15467
Reasons why the SMS may not have been delivered:
NXSMS
. For details on support of alphanumeric sender ID see:
https://docs.nexmo.com/messaging/sms-api/building-global-apps#country_specific_featuresOne way to improve the chances of deliverability is to use a from
number that has been bought through Nexmo. In these examples there is also a callback
parameter set so that the application is informed of the SMS delivery.
Using using the Nexmo PHP client library:
<?php
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET));
$message = $client->message()->send([
'to' => '90542xxxxxxx',
'from' => '90555xxxxxxx',
'text' => 'Working',
'callback' => 'https://example.com/dlr;
]);
Or based on the code in the question:
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'xxxxxxxx',
'api_secret' => 'xxxxxxxxxxx',
'to' => '90542xxxxxxx',
'from' => '90555xxxxxxx',
'text' => 'Working',
'callback' => 'https://example.com/dlr;
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
Related: Nexmo FAQ on SMS delivery in Turkey
Upvotes: 1