I want to access https://graph.facebook.com/19165649929?fields=name (obviously it is also available with "http") using cURL to get the contents of the file, more specific: I need a "name" (this is json ) Since allow_url_fopen is disabled on my web server, I cannot use get_file_contents! So I tried it like this:
<?php
$page = 'http://graph.facebook.com/19165649929?fields=name';
$ch = curl_init();
//$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
//curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_URL, $page);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>
With this code, I get a blank page! When I use another page, for example http://www.google.com , it works like a charm (I get the contents of the page). I think facebook is checking what I don't know ... What could it be? How can I make the code work? Thank!
source
share