[英]how to get user access token while using facebook connect with PHP SDK3.0
嘿嘿,我有情況。 我使用 php sdk3.0 連接 facebook 並希望在我的網站上使用 facebook id 登錄用戶。 我將當前用戶的詳細信息保存到我的數據庫中,我怎樣才能讓用戶訪問令牌稍后再使用它。
嘗試這樣的事情
<?php
if ($_REQUEST['code']) {
$app_id = "<app id>";
$app_secret = "<secret key for your app>";
$my_url = "<url to your app>";
$code = $_REQUEST["code"];
$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret="
. $app_secret . "&code=" . $code;
$access_token = file_get_contents($token_url);
$graph_url = "https://graph.facebook.com/me?" . $access_token;
$user = json_decode(file_get_contents($graph_url));
echo $access_token . "<br />";
echo $user->name . "<br />";
echo $user->id . "<br />";
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.