0
我想從Facebook頁面中提取事件到官方網站,並與圖表和oauth進行鬥爭以獲取信息。如何從Facebook頁面提取事件頁面
簡化的代碼,相位1 & 2中相同的代碼:
<?php
$app_id = '...........4639';
$app_secret = '7547xxxxxxxxxxxxxxxxxxxxxxxx';
if (isset($_GET['code'])) {
//stage 2
$state = $_GET['state'];
$code = $_GET['code'];
//the code doesn't work. If I use graph api explorer to get key, I'm all fine.
//the code here from graph api explorer.
//$code = 'AAAIERWeZCHZxxxxxxxxxxxxxxxxxxxxx';
$s = "https://graph.facebook.com/_PAGE_ID?fields=feed.fields(story,message,picture)&access_token=" . $code;
$json = file_get_contents($s);
die($json);
} else {
//stage 1
$my_url = 'http://www.myself.com/fb/index.php';
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" .
$app_id . "&redirect_uri=" . urlencode($my_url) . "&state=" . $_SESSION['state'];
//now redirect to myself - phase2
header("Location: " . $dialog_url);
exit();
}
是的,你需要一個應用程序。要訪問信息,請獲取頁面訪問令牌:https://developers.facebook.com/docs/howtos/login/login-as-page/ – CBroe 2013-03-14 12:51:27
@CBroe,感謝您的提示。請進一步協助,我很無能... – Teson 2013-03-14 14:57:05
如果您想要具體的信息,請提出具體問題。 – CBroe 2013-03-14 14:59:31