Facebook的图形API和放大器; PHP SDK问题 [英] Facebook graph API & PHP SDK questions
问题描述
我使用Facebook的图形API的几个问题。
1)。
当我尝试上传照片我得到以下错误(#324)需要上传的文件。
$ attachement =阵列(
ACCESS_TOKEN'=> (......),
'名'=> 上传照片,
'源'=> C:\\ Documents和Settings \\用户名\\桌面\\ 1.JPG
); $ fb_foto = $ FB-GT&; API(ME /照片,POST,$ attachement);
我相信,来源是正确的。我试图从互联网,而不是从当地每亩也PC中的照片。
2)。如何删除从Facebook的对象? (例如墙壁消息)。
我已经试过这样:
$ FB-> API('/ POST_ID,POST,阵列('方法'=>'删除'));
但我得到不支持POST请求的错误。
任何帮助将是AP preciated。
编辑:这里是完整的解决方案,我发现上传照片到Facebook。你需要有PHP SDK版本2.1.1或以上
$ FB =新的Facebook(阵列(
APPID=> ...
'秘密'=> ...
'饼干'=>真正,
));$ FB-GT&; setFileUploadSupport(真);
$ attachement =阵列(
ACCESS_TOKEN'=> '...',
'名'=> 上传照片,
'源'=> @absolute_path_to_the_file
); $ fb_foto = $ FB-GT&; API(ME /照片,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屋!