3

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: [email protected] 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.

1 Answer 1

4

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); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.