Reputation: 433
I have a url of a Facebook page. I want to be able to grab the image from the url, however the server that I am using is operating in cURL safe mode. I am trying to save the image to my server. I have made some attempts at it, however, all of the attempts I have made have resulted in an error due to my servers limited capabilities. Is this even possible without cURL?
Example of what I have so far:
<?
function getImages($url) {
$ch = curl_init();
curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER, true));
$results = curl_exec($ch);
$doc = new DOMDocument();
$doc->loadHTML($results);
$images = $doc->getElementsByTagName('img');
return($images);
}
getImages('http://t.co/vPnWwPy8');
?>
EDIT: The error I receive is:
Warning: curl_setopt_array() [function.curl-setopt-array]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set
Thanks!
Upvotes: 0
Views: 226
Reputation: 669
You can use file_get_contents().
https://www.php.net/manual/en/function.file-get-contents.php
Upvotes: 2