file_get_contents() problem, works fine in Local not in server
I am trying to send an SMS using an API.
Using file_get_contents()
, the message is sent suce开发者_JS百科ssfully 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?
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.
You may have a web host which does not allow file operations. This is quite common on some non-dedicated hosting services.
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.
精彩评论