Reputation:
I am trying to make this request
fopen("http://192.168.0.116:9090/sendsms?phone=4456666&text=url#&password=","r");
to send an sms from my android device but i can't seem to send the message successfully and i suspect that #
is complicating things.
The #
in url must remain there as part of the message itself.
phone
is the telephone number and text
is the text message.
How can i make the get request work?.
Upvotes: 1
Views: 433
Reputation: 13683
This shall work
fopen("http://192.168.0.116:9090/sendsms?phone=4456666&text=url%23&password=","r");
as #
is %23
Upvotes: 1
Reputation: 41958
Yes, the #
character indicates a fragment in URLs, so the part after that is actually ignored right now. You need to escape it properly, for example like this:
$myUrl = 'http://192.168.0.116:9090/sendsms?'.http_build_query([
'phone' => '4456666',
'text' => 'url#',
'password' => '',
]);
Docs here on `http_build_query'.
You can also properly escape the individual values with urlencode
.
Upvotes: 2