Last active
December 24, 2016 23:42
-
-
Save alshakero/69f2a741a358a4f51863acd444138a4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Access-Control-Allow-Origin: http://www.alhazen.co', false); | |
if(!(strpos($_SERVER["HTTP_REFERER"], "http://www.alhazen.co") !== false)) | |
{ | |
echo "Why so curious?"; | |
exit; | |
} | |
sleep(2); | |
$id = $_POST['id']; | |
if(!is_numeric($id)) { | |
echo "Bad FB id"; | |
return; | |
} | |
function getData($id) | |
{ | |
$token = YOUR_APP_ACCESS_TOKEN; | |
$ch = curl_init(); | |
$timeout = 5; | |
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/v2.8/$id?fields=source,title&access_token=$token"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, 'Content-Type:application/json'); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
return $data; | |
} | |
echo getData($id); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment