Facebook 图形 API 和PHP SDK 问题

2022-01-08 00:00:00 api upload sdk php facebook

我在使用 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 SettingsUsernameDesktop1.jpg'
                    );

        $fb_foto = $fb->api('me/photos','POST',$attachement);

我确信来源是正确的.我尝试使用来自互联网的照片,而不是来自本地 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

相关文章