Yakir Sayada
Yakir Sayada

Reputation: 181

PHP send SMS with nexmo

i'm using nexmo services to send SMS to specific number IN HEBREW, but the message arrived as %D7%AA%D7. (My language is PHP), this is my code:

$message = $_REQUEST["message"];

//Build the url 
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
    [
      'api_key' =>  '******',
      'api_secret' => '*******',
      'to' => '9725433131',
      'from' => '4416329600',
      'text' => urlencode($message)
    ]
);
//Send the data
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
$response = curl_exec($ch);

echo $response;

Upvotes: 2

Views: 1288

Answers (1)

Kostis
Kostis

Reputation: 1105

Try adding the type parameter in the request.

//Build the url 
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
      'api_key' =>  '******',
      'api_secret' => '*******',
      'to' => '9725433131',
      'from' => '4416329600',
      'text' => urlencode($message),
      'type' => 'unicode'
    ]
);

You can find more info in the nexmo documentation page.

Upvotes: 2

Related Questions