Reputation: 99
I am trying to send an SMS using an API.
Using file_get_contents()
, the message is sent sucessfully from my local machine, but it's not working on my server. I get this warning:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /usr/home/....
How can I fix this?
Upvotes: 0
Views: 963
Reputation: 1
I solved this issue by using the IP of the domain and it was successful Like:
$homepage = file_get_contents('http://1.1.1.11/');
Used IP of my domain.
Upvotes: 0
Reputation: 8719
Many (free or cheap) shared-hosting providers forbid server-to-server requests, so you can't do:
file_get_contents('http://some.external.io/request');
You may be able to circumvent this using cURL, stream/fopen functions, or other extensions, but you shouldn't count on it... get a better host if you want to do this kind of thing.
Upvotes: 1
Reputation: 141827
You may have a web host which does not allow file operations. This is quite common on some non-dedicated hosting services.
Upvotes: 0