Reputation: 708
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
Upvotes: 0
Views: 2350
Reputation: 253
Set dcs coding =8 and convert your Hindi characters into Unicode characters and put it in the text field.This will work.
Upvotes: 0
Reputation: 99
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.
Upvotes: 1