Facebook 图 API &PHP SDK 问题 [英] Facebook graph API & PHP SDK questions
问题描述
我在使用 facebook graph api 时遇到了一些问题.
I have a couple of problems using facebook graph api.
1).当我尝试上传照片时,出现以下错误(#324) 需要上传文件".
1). When i try to upload a photo i get the following error "(#324) Requires upload file".
$attachement = array(
'access_token'=> (...)',
'name' => 'uploaded foto',
'source' => 'C:\Documents and Settings\Username\Desktop\1.jpg'
);
$fb_foto = $fb->api('me/photos','POST',$attachement);
我确定来源是正确的.我已经尝试过使用来自互联网的照片,而不是来自 mu 本地 PC 的照片.
I am sure that source is correct. I have tried with a photo from the internet and not from mu local PC also.
2).如何从 Facebook 中删除对象?(例如墙上的消息).我试过这个:$fb->api('/post_id','POST',array('method'=> 'delete'));
2). How can i delete an object from facebook?. (a wall message for example). I have tried this: $fb->api('/post_id','POST',array('method'=> 'delete'));
但我收到不支持的 POST 请求"错误.
But i get "unsupported POST request" error.
任何帮助将不胜感激.
这是我找到的将照片上传到 Facebook 的完整解决方案.需要PHP SDK 2.1.1及以上版本
$fb = new Facebook(array(
'appId' => ...,
'secret' => ...,
'cookie' => true,
));
$fb->setFileUploadSupport(true);
$attachement = array(
'access_token'=> '...',
'name' => 'uploaded foto',
'source' => '@absolute_path_to_the_file'
);
$fb_foto = $fb->api('me/photos','POST',$attachement);
推荐答案
关于你的第二个问题,我记得在某处读到过关于 DELETE 请求而不是 POST 的内容.看:http://developers.facebook.com/docs/api#deleting
Concerning your 2nd problem, I remember reading somewhere about a DELETE request, instead of POST. See: http://developers.facebook.com/docs/api#deleting
这篇关于Facebook 图 API &PHP SDK 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!