你需要
access_token
从您的帐户获取提要。您无法使用其他令牌接受此令牌。
因此,如果你有一个后端服务器(我想你肯定有),这对你来说会更容易。你可以写一个小脚本,在那里你可以调用facebook
登录
然后获取正常访问令牌
延伸
它的有效期为60天,并将其保存到数据库中,并注明其过期日期。在它到期之前,只需运行脚本,令牌就会被刷新。您的主网站将始终从数据库中获取令牌。
很简单。我不认为你还能做什么。
如果你对这样的剧本感兴趣,我可以帮你-
$code = $_REQUEST["code"];
if(empty($code))
{
$dialog_url= "http://www.facebook.com/dialog/oauth?"
. "client_id=" . $APP_ID
. "&redirect_uri=" . urlencode( $post_login_url);
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
else
{
// access token
$token_url = "https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $APP_ID
. "&redirect_uri=" . urlencode( $post_login_url)
. "&client_secret=" . $APP_SECRET
. "&code=" . $_REQUEST["code"];
$response1 = file_get_contents($token_url);
$params = null;
parse_str($response1, $params);
$access_token = $params['access_token'];
// extended token
$extended_token_url = "https://graph.facebook.com/oauth/access_token?"
. "grant_type=fb_exchange_token"
. "&client_id=" . $APP_ID
. "&client_secret=" . $APP_SECRET
. "&fb_exchange_token=" . $access_token;
$response2 = file_get_contents($extended_token_url);
$response2 = json_decode($response2);
$extended_access_token = $params['access_token']; // save this to the database with the expiration date(current date+60days)
}