PHP - 卷曲给我?????阿拉伯文字

时间:2017-08-01 18:59:23

标签: php api curl

我有php代码:

$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);

但我得到了这个结果'?????????阿拉伯文字

1 个答案:

答案 0 :(得分:1)

您必须使用urlencodehttp_build_query作为网址参数。

例如:

...
$text_message=urlencode("تجربة");
...