I\'m developing a web application for sending SMS to mobile from website like 160by2.
I can prepare the URL required for the HTTP GET request as mentioned in the API pro
Your problem is the way you are constructing the URL. The spaces you are including in the query string will result in a malformed request URL being sent.
Here is an example that replicates your circumstances:
request.php:
response.php:
The output of request.php is:
Array
(
[foo] => yes
)
The reason for this is the query string is not properly encoded and the server interpreting the request assumes the URL ends at the first space, which in this case is in the middle of the query: foo=yes we can&baz=foo bar
.
You need to build your URL using http_build_query, which will take care of urlencoding your query string properly and generally makes the code look a lot more readable:
echo http_build_query(array(
'user'=>'abc',
'password'=>'xyz',
'msisdn'=>'1234',
'sid'=>'WebSMS',
'msg'=>'Test message from SMSLane',
'fl'=>0
));
You also need to set CURLOPT_RETURNTRANSFER:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);