在登錄FB時的scope請加上user_about_me權限
登錄FB完後會自動導到你指定redirect_uri並代上$_GET['code']變數
# short-lived access token
'https://graph.facebook.com/oauth/access_token?client_id='.$appId.'&redirect_uri=http://local.dev/fbv2.php&client_secret='.$secret.'&code='.$_GET['code'];
response會類似下列:
access_token=CAADufk.............................Bu2W2GYj3ZB6RKUQZD&expires=5157494
# long-lived access token
'https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id='.$appId.'&client_secret='.$secret.'&fb_exchange_token='.$shortLivedAccessToken;
response會類似下列:
access_token=CAADufk............................aJd0ZD&expires=5157389
60天內要查某FB會員資訊得在node_id代上?access_token=$longLivedAccessToken即可
ex: 'https://graph.facebook.com/fbUserId/likes?access_token='.$longLivedAccessToken;
新版可參考這篇
回覆刪除http://goodjack.blogspot.tw/2017/08/how-to-get-facebook-permanent-page-access-token.html