无法使用 Facebook Graph API 上传图片
我在将图片上传到用户相册时遇到问题。
应用程序要求“req_perms”=> '发布流,用户照片' 我正在这样做:
$fb = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_SECRET_ID,
'cookie' => true,
'fileUpload' => true,
));
$fb->setFileUploadSupport(true);
$photo_details = array(
'message'=> 'Retrouve cette recette surhttp://apps.facebook.com/betaaa'
);
$file='/img/bar.png'; //Example image file
$photo_details['image'] = '@'.realpath($file);
echo '@'.realpath($file);
//echo '/me/'.$album_uid.'/photos';
$upload_photo = $fb->api('/me/photos', 'post', $photo_details);
但我总是收到这样的消息:
致命错误:未捕获 OAuthException:(#1) 发生未知错误 抛出
我还使用 $post = $fb->api('/me/feed', 'post', $recette_post_details); 发布提要; 这是有效的...
有人对这个问题有想法吗?
谢谢。
I've got a problem to upload a picture to a user album's.
The application ask for 'req_perms' => 'publish_stream,user_photos'
I'm doing this :
$fb = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_SECRET_ID,
'cookie' => true,
'fileUpload' => true,
));
$fb->setFileUploadSupport(true);
$photo_details = array(
'message'=> 'Retrouve cette recette surhttp://apps.facebook.com/betaaa'
);
$file='/img/bar.png'; //Example image file
$photo_details['image'] = '@'.realpath($file);
echo '@'.realpath($file);
//echo '/me/'.$album_uid.'/photos';
$upload_photo = $fb->api('/me/photos', 'post', $photo_details);
but I all the time get this message:
Fatal error: Uncaught OAuthException: (#1) An unknown error occurred
thrown
I'm also publishing feeds with $post = $fb->api('/me/feed', 'post', $recette_post_details);
and this is working...
Somebody has an idea about this problem?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请检查您是否有权为您的申请发布照片“publish_stream”。
或者
通常是将 access_token 数据放入请求中。
我不熟悉 PHP,但我们可以获取 access_token 并将其附加在 /me/photos/access_token=... 之后
我已经在 AIR 平台上这样做了,通过将
access_token
数据插入到帖子中消息,在本例中是您的 $photo_details。请尝试一下,如果有效请告诉我。
Please check whether you have permission to post photo "publish_stream" for your application.
Or
It's usually about putting access_token data into the request as well.
I'm not familiar with PHP, but we could get access_token and append it after /me/photos/access_token=...
I have done like this on AIR platform, by insert
access_token
data into the post message, in this case your $photo_details.Please try it, let me know if it works.