-2

I have the php code:

$text_message="تجربة";
$user_phone="xxxxxxx";
$type_sms="ArabicWithLatinNumbers";
$url= "https://xxxx/HTTP_SendSms?customerID=xxxxx&userName=xxxxxx&userPassword=xxxxxxxx&originator=xxxxxx&smsText={$text_message}".
"&recipientPhone={$user_phone}&messageType={$type_sms}&defDate=&blink=false&flash=false&Private=false";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml;charset=utf-8"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);

but i got this result '?????????' with Arabic text

Fray
  • 250
  • 2
  • 5
  • 16
  • You need to tell us what you're expecting to get back and _show_ us what you're actually are getting. We have _no idea_ what is correct and not. Generally, I would say that if you get a successful response but with unexpected content, you should contact the API-owners. – M. Eriksson Aug 01 '17 at 19:00
  • There is absolutely nothing here we can help with. What is the endpoint you are truely hitting? Do you own it? What is the code running there? What do you expect to see as a response? Many details lacking to make this answerable. – Matt Clark Aug 01 '17 at 19:02
  • This could happen if the script handling the curl (`https://xxxx/HTTP_SendSms`) is encoded in ANSI or returns the result in a different encoding to utf8. – Dan Aug 01 '17 at 19:03
  • @MattClark i can't share the API parameters,(this is an API to send mobile text message to a user) it works good with English text, the prob is , with encoding to utf8 (Arabic characters) – Fray Aug 01 '17 at 19:08
  • @MagnusEriksson This is an API to send mobile text message to a user phone, i have a problem with Arabic characters. – Fray Aug 01 '17 at 19:09
  • You dont have to post your API parameters, obviously, but even the service provider, if not your own code, is better then nothing. Try [debugging CURL](https://stackoverflow.com/a/14436877/1790644) and posting the output back in your question body to better help to debug your issues. – Matt Clark Aug 01 '17 at 19:10
  • You could try to change the charset to something that works with Arabic characters? (I have no idea what that is, though) – M. Eriksson Aug 01 '17 at 19:13
  • @MagnusEriksson this parameter `$text_message="تجربة";' will be like this on result '???????????' because it's on Arabic (the result is a text message on mobile phone) – Fray Aug 01 '17 at 19:19

1 Answers1

2

You must use urlencode or http_build_query for your url parameters.

For example:

...
$text_message=urlencode("تجربة");
...
Neodan
  • 5,154
  • 2
  • 27
  • 38