Facebook图形API& PHP SDK问题 [英] Facebook graph API & PHP SDK questions
问题描述
1)。
当我尝试上传照片时,我得到以下错误(#324)需要上传文件。
$ 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本地电脑。
2)。如何从Facebook上删除一个对象? (例如墙上的消息)。
我已经尝试过:
$ fb-> api('/ post_id','POST',array('method'=>'delete'));
但是我得到不支持的POST请求错误。
任何帮助将不胜感激。
编辑:这是我发现将照片上传到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
I have a couple of problems using facebook graph api.
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);
I am sure that source is correct. I have tried with a photo from the internet and not from mu local PC also.
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'));
But i get "unsupported POST request" error.
Any help would be appreciated.
EDIT: Here is the complete solution i found for upload photos to Facebook. You need to have the version 2.1.1 or above of PHP SDK
$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);
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屋!