Facebook 图形 API 和PHP SDK 问题 [英] Facebook graph API & PHP SDK questions

查看:31
本文介绍了Facebook 图形 API 和PHP SDK 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 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

这篇关于Facebook 图形 API 和PHP SDK 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆