I try to get content from my facebook page like so:
echo file_get_contents("http://www.facebook.com/dma.y");
The problem is that it doesnt give me the page but redirects me to another page that says that I need to upgrade my browswer. Then I thought to use curl and fetch it by sending a request with some headers.
echo get_follow_url('http://www.facebook.com/dma.y');
function get_follow_url($url){
// must set $url first. Duh...
$http = curl_init($url);
curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($http, CURLOPT_HTTPHEADER, get_headers('http://google.com'));
// do your curl thing here
$result = curl_exec($http);
if(curl_errno($http)){
echo "<br/>An error has been thrown!<br/>";
exit();
}
$http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
curl_close($http);
return $http_status;
}
Still there is no luck. I should have a status code response returned which is either 404 or 200.. depending if I am logged into facebook. But it returns 301, cause it identifies my request as not being a regular browser request. so what am I missing in the curl option settings?
UPDATE What I am actually trying to do is to replicate this functionality:
The script will trigger the function onload or onerror, depending on the status code returned..
That code will retrieve the page. However, that javascript method is clumsy, and breaks in some browsers like firefox..cause it isnt a javascript file.