Reputation: 97
I have a URL like this:
http://x.x.x.x/feedsms?to=$groupName&text=$content"
When I call this url it should send a SMS.
I have used file_get_contents()
to read the SMS content and urlencode()
because of the spaces and special characters:
$url = urlencode("http://x.x.x.x/feedsms?to=$groupName&text=$content");
$urlContent = file_get_contents($url);
The $content
is something like this:
F: user@domain.com S: Veeam Repoting B: Target: y.y.y.y, Status: Error, Time: 8/22/2015 3:05:30 PM
But I can't call the url:
file_get_contents(): failed to open stream: No such file or directory ...
Also I used rawurlencode()
, but nothing changed.
Upvotes: 3
Views: 1675
Reputation: 3010
urlencode should be used, as docs says, to encode a string to be used in a query part of a URL. You should not use it on your entire URL but only for every parameter that should be encoded, in your case $groupName
and $content
. Something like this should do the trick:
$url = "http://x.x.x.x/feedsms?to=" . urlencode($groupName) . "&text=" . urlencode($content);
Upvotes: 4