Facebook 照片上传错误
您好,我正在尝试编写一个 Facebook 应用程序,将照片发布到用户页面。我已经逐字逐句地遵循了这个教程。
但每当我尝试上传照片时,我都会收到此错误:
{
"error": {
"type": "OAuthException",
"message": "A user access token is required to request this resource."
}
}
我相信问题来自此代码,因为我正在发送 AppID、AppSecret 和 post_login_url (均已正确填充),但是 $response 完全空白:
$token_url= "https://graph.facebook.com/oauth/"
. "access_token?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
任何帮助都会不胜感激,一如既往,我的截止日期很紧,
谢谢,
道格
Hi Im trying to write a facebook application that will post a photo to a users page. Ive pretty much word for word followed this tutorial.
but whenever I try and upload a photo I get this error:
{
"error": {
"type": "OAuthException",
"message": "A user access token is required to request this resource."
}
}
I beleive the problem is coming from this code as I'm sending the AppID, AppSecret and post_login_url (which are all correctly populated) however $response is completely blank:
$token_url= "https://graph.facebook.com/oauth/"
. "access_token?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
Any help would be appreciated, as always im on a tight deadline
Thanks,
Doug
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应用程序访问令牌用于代表应用程序进行 API 调用,您的根本问题可能是您尝试进行的 API 调用必须代表用户进行,并且需要用户访问令牌时生成的用户访问令牌授权您的应用程序。
您上面的代码应该可以很好地获取应用程序访问令牌
The Application Access token is used to make API calls on behalf of an app, your underlying issue is likely that the API call you're trying to make has to be made on behalf of a User and needs a user access token produced when a user authorises your app.
The code you have above should be fine for getting an App Access token