Search code examples
phpvonage

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;

Solution

  • 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.