dongmie3987067 2014-04-03 07:46
浏览 40

无法用印地语发送短信

I need to send SMS in hindi, for this I need to pass the hindi string through URL.

As I am coading in php I used urlencode($hindimessage) on string and passed complete URL through file_get_contents(). On executing I got error:

Warning: file_get_contents(http://IP GOES HERE/smpp/sendsms?username=$name&password=******&to=$contact&from=DEMOTT&coding=3&&text=%E0%A4%AE%E0%A4%A8%E0%A5%80%E0%A4%B7+%E0%A4%95%E0%A5%81%E0%A4): failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported

Without using urlencode(), the server treats text as EMPTY STRING and rejects.

I also tried Using utf8_encode() encoding. I recive message in HTML tags like ही....

But when I use the API URL directly I am able to recive the message in hindi since API is Unicode API coding=3 enbled for Hindi text.(i.e API is working Properly)

Please Inform what kind of approach I need to adopt for sending message in both Hindi as well as in English.

Thanks in Advance

  • 写回答

2条回答 默认 最新

  • dongtan5558 2017-08-23 09:32
    关注

    urlencode() is necessary if you are calling URL in file_get_contents() function.

    You need to adopt CURL for sending message in both Hindi as well as in English.

     $smsgatewayurl = 'http://IP GOES HERE/smpp/sendsms';
     $post_data = array(); // All params including text message
    
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $smsgatewayurl);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
     $output = curl_exec($ch);
     curl_close($ch);
    

    CURL is best option to call third party APIs compare to file_get_contents function. I have tested this above function with spring edge sms gateway including hindi text.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向