如何在Facebook上使用SDK的“manage_pages”权限? [英] How can I use 'manage_pages' permission with the SDK on Facebook?

查看:93
本文介绍了如何在Facebook上使用SDK的“manage_pages”权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个在扇形页面上显示为选项卡的应用程序。粉丝专页的管理员给我权限 manage_pages ,然后将我的申请表标签添加到他的粉丝页面。

I create an application which appears as a tab on fan page. The administrator of the fan page give me the permission manage_pages and then the tab of my application is added to his fan page.

问题是我没有找到关于如何使用PHP SDK的权限的示例代码。我查看SDK的文件 base_facebook.php ,我想我应该使用函数 getApiUrl ,但是我不确定,可能我不知道如何使用这个功能。

The problem is that I didn't find any example code on how to use this permission with the PHP SDK. I looked in the file base_facebook.php of the SDK, and I guess that I should using the function getApiUrl, but I'm not sure and probably I don't know how using this function.

推荐答案

现在你有了manage_pages权限,采取访问令牌,将其传递到像下面创建的方法,以获取访问令牌来管理页面。每个页面都有自己的访问令牌,您需要在manage_pages权限之后使用。

Now that you have the manage_pages permission, take the access token, pass it into a method like the one I've created below to get an access token to manage the page. Each page has its own access token that you need to use once you have the manage_pages permission.

function get_page_access_token($page_id, $access_token, $user_id) {
    $data = file_get_contents('https://graph.beta.facebook.com/'.$user_id.'/accounts?access_token='.$access_token);
    $pages = json_decode($data,true);
    foreach($pages['data'] as $page) {
      if($page['id'] == $page_id) {
        return $page['access_token']; 
      }   
   }
}

这篇关于如何在Facebook上使用SDK的“manage_pages”权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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