我正在尝试使用以下代码为我的一个页面获取长期访问令牌:
$page_info = $facebook->api("/page-id?fields=access_token");
$args = array(
"client_id" => $facebook->getAppId(),
"client_secret" => $facebook->getAppSecret(),
"grant_type" => "fb_exchange_token",
"fb_exchange_token" => $page_info["access_token"]
);
$result = $facebook->api("/oauth/access_token", $args);
echo json_encode($result);
...但我得到这个响应: {"error_code":1,"error_msg":"An unknown error occurred"}
如果我浏览到,我会得到相同的响应
https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN
如https://developers.facebook.com/roadmap/offline-access-removal/#page_access_token中所述