<?php
/** me@dwisiswanto.my.id **/
function curl($url, $postData = null, $head = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if ($postData != null){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
if ($head != null) {
curl_setopt($ch, CURLOPT_HEADER, true); // Handle the headers response
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
}
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1");
$exec = curl_exec($ch);
curl_close($ch);
return array($exec, explode("\\n", $exec));
}
function getToken($appId, $scope, $cookie) {
if (empty($scope)) {
$scope = "";
}
$njaluk = curl("https://www.facebook.com/v2.5/dialog/oauth?response_type=token&display=popup&client_id=" . $appId . "&redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer%2Fcallback&scope=" . $scope, null, array("Cookie: " . $cookie));
if (preg_match("/#access_token=(.*)/i", $njaluk[1][1], $token)) {
return explode("&", $token[1])[0];
} else {
return "Uh, oh! We have some problems."; // Check back your cookies
}
}
/*
145634995501895 (bellow) is an Facebook applications ID (Graph API Explorer apps)
You can write blank in $scope variables, if have previously authorize the same applications ID
How to Get Facebook\'s Cookie (http://aingcreations-scripts.blogspot.co.id/2015/09/how-to-get-facebooks-cookie.html)
*/
echo getToken("145634995501895", "", "datr=...; fr=...; lu=...; s=...; csm=...; xs=...; c_user=...; act=...; p=...; presence=...; wd=...");
// You can develop this script by using COOKIEJAR on curl.