0
我試圖使用這種方法使用圖形API,但它不會返回狀態消息......有無論如何,我可以拉這些?我怎樣才能得到用戶關注的Facebook頁面的提要。例如可口可樂的頁面..如果我喜歡它,我如何檢索它的提要?答案將不勝感激!我怎樣才能使用圖形API拉用戶的Facebook狀態消息
$status = $facebook->api("/690196511");
我試圖使用這種方法使用圖形API,但它不會返回狀態消息......有無論如何,我可以拉這些?我怎樣才能得到用戶關注的Facebook頁面的提要。例如可口可樂的頁面..如果我喜歡它,我如何檢索它的提要?答案將不勝感激!我怎樣才能使用圖形API拉用戶的Facebook狀態消息
$status = $facebook->api("/690196511");
試試這個代碼:
<?php
$facebook_appid = "facebook_appid"; // Facebook appplication id
$facebook_secret = "facebook_secret"; // Facebook secret id
$facebook_pageid = "facebook_pageid"; // Facebook secret id
$redirect_uri = "https://localhost/facebook_page/events.php"; // return url to our application after facebook login ## should be SAME as in facebook application
//$redirect_uri = "https://localhost/facebook_page/fb_login.php"; // return url to our application after facebook login ## should be SAME as in facebook application
$scope = "user_photos,email,user_birthday,user_online_presence,offline_access,manage_pages,publish_stream,user_events,friends_events"; // User permission for facebook
$code = $_REQUEST["code"]?$_REQUEST["code"]:"";
if(empty($code)) {
$_SESSION['state'] = time(); // CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=". $facebook_appid . "&redirect_uri=" . urlencode($redirect_uri) . "&state=". $_SESSION['state'] . "&scope=".$scope;
header("location:".$dialog_url);
}
if($_SESSION['state'] && ($_SESSION['state'] == $_REQUEST['state'])) {
$token_url = "https://graph.facebook.com/oauth/access_token?". "client_id=" . $facebook_appid . "&redirect_uri=" . urlencode($redirect_uri). "&client_secret=" . $facebook_secret . "&code=" . $code;
$response = @file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$account_url = "https://graph.facebook.com/".$facebook_pageid."?fields=access_token&access_token=".$params['access_token'];
$resp = @file_get_contents($account_url);
$dt = json_decode($resp);
echo $dt->access_token;
echo "<br>";
echo $dt->id;
$offer_url = "https://graph.facebook.com/".$dt->id."/feed?access_token=".$dt->access_token;
$off = @file_get_contents($offer_url);
$dto = json_decode($off);
echo "<pre>";
print_r($dto);
}
?>
讓我知道,如果你有代碼的任何問題。 – 2013-02-28 06:15:32
它實際上工作... – user2070701 2013-03-02 19:11:18