How can I get the html source code of http://www.example-webpage.com/file.html without using file_get_contents()?
I need to know this because on some webhosts allow_url_fopen is disabled so you can’t use file_get_contents(). Is it possible to get the html file’s source with cURL (if cURL support is enabled)? If so, how?
Thanks.
Try the following:
I would only recommend this for small files. Big files are read as a whole and are likely to produce a memory error.
EDIT: after some discussion in the comments we found out that the problem was that the server couldn’t resolve the host name and the page was in addition a HTTPS resource so here comes your temporary solution (until your server admin fixes the name resolving).
what i did is just pinging graph.facebook.com to see the IP address, replace the host name with the IP address and instead specify the header manually. This however renders the SSL certificate invalid so we have to suppress peer verification.
Keep in mind that the IP address might change and this is an error source. you should also do some error handling using
curl_error();.