我正在尝试使用以下代码为我的一个页面获取长期访问令牌:
$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":"发生未知错误"}
如果我浏览到
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 所述
如果我
正确阅读了您的代码,您将页面的access_token
传递到该端点,这不是文档所说的 - 您需要将页面管理员的短期access_token
换成长期令牌,并使用该长期令牌获取页面access_token