Asım Gündüz
Asım Gündüz

Reputation: 1297

Receiving sms fails on Nexmo Send Sms

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

Answers (1)

leggetter
leggetter

Reputation: 15467

Reasons why the SMS may not have been delivered:

  1. An alphanumeric sending is being used in a region where such a sender ID is not allowed to be used. This is a legal requirement for the region of Turkey (+90). In this case Nexmo will change the sender ID to NXSMS. For details on support of alphanumeric sender ID see: https://docs.nexmo.com/messaging/sms-api/building-global-apps#country_specific_features
  2. The carrier failed to deliver the message. It is possible (and recommended) to set up a webhook callback so that your app is informed of delivery receipts. See https://docs.nexmo.com/messaging/sms-api/api-reference#delivery_receipt

One 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

Related Questions