如何发布照片到使用API​​的Facebook页面(粉丝专页)的专辑? [英] How to post photos into the album of Facebook page(fanpage) using API?

查看:163
本文介绍了如何发布照片到使用API​​的Facebook页面(粉丝专页)的专辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Facebook页面的管理员。
并开发使用PHP和Facebook API的一些应用程序。
我想要做的是将照片上传到Facebook页面上指定的专辑。
在这一刻,我已经张贴到album_id后得到了下面的错误信息。搜索结果
   错误:{
      类型:OAuthException,
      消息:(#120)无效的相册ID

I'm building a Facebook page as administrator. And developing some apps using PHP and Facebook API. What I'd like to do is to upload photos into the specified album on the Facebook page. At this moment, I've got following error message after posting into the album_id.

"error": { "type": "OAuthException", "message": "(#120) Invalid album id"

然后,我想知道follofing的事情。
如何获得的Facebook页面不适合我的access_token。
权限(user_photos,publish_stream,manage_pages,photo_upload)足够?
最后,如​​果你有一些经验,请告诉我成功的样本code?

Then, I'd like to know follofing things. How to get the access_token for the Facebook page not for me. The permissions (user_photos,publish_stream,manage_pages,photo_upload) are enough? Finally, if you have some experience, please show me the successful sample code?

推荐答案

要获得页面的访问令牌,试试这个:

To get the access token for the page, try this:

$page_token_url = "https://graph.facebook.com/" . 
  $page_id . "?fields=access_token&" . $access_token;
$response = file_get_contents($page_token_url);
$resp_obj = json_decode($response,true);
$page_access_token = $resp_obj['access_token'];

有关权限 publish_stream manage_pages 就足够了。

有关实际张贴的形象,我在做这个(工作):

For actually posting the image, I'm doing this (which works):

$ch = curl_init("https://graph.facebook.com/$album_id/photos/");  
curl_setopt($ch, CURLOPT_POSTFIELDS,
    array('access_token'=>$page_access_token,
    'source'=>"@$filename",
    'message'=>$caption,
    'description'=>$message));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$rtn = curl_exec($ch);
curl_close($ch);
echo $rtn;

这篇关于如何发布照片到使用API​​的Facebook页面(粉丝专页)的专辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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