如何使用图形api访问令牌在PHP的Facebook sdk [英] how to use graph api access token in php for facebook sdk

查看:142
本文介绍了如何使用图形api访问令牌在PHP的Facebook sdk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的坚持这个问题。

我一直在阅读文档,我不明白如何使用访问令牌我的页面,以便我可以拉页面的消息。

I've been reading the documentation over and over and I don't understand how to use the access token for my page, so that I could pull the page's messages.

这是我的代码:

$user_id = $facebook->getUser();
if($user_id) {
    $user_profile = $facebook->api('/me/accounts', 'GET');
}

然后我得到一个数组,有两个键:数据分页

and then I get an array, with two keys: data and paging

code>我得到一个我拥有的页面数组,其中access_token可用于每个页面。

Inside of data I get an array of the pages I own, where the access_token is available for each page.

根据此页面:

https://developers.facebook.com/docs/graph-api/reference/page

我可以通过调用边缘来访问我的页面的收件箱:

I should be able to access my page's inbox by calling the edge:

/ {page_id} /对话

但是当我这样做:

$ facebook-> ; api($ page_id。'/ conversations','GET');

将使用以下消息抛出FacebookApiException:

The FacebookApiException is thrown with the message:

(#10)应用程序没有此操作的权限

但我确信我有权采取行动。我确定它与访问令牌有关,但我只是不知道该怎么做。

but I'm sure I've permission for that action. I'm sure it has something to do with the access token, but I just don't know what to do with it.

我缺少什么?如何使用我的页面的访问令牌来阅读我的收件箱?

What am I missing? How do I use my page's access token to read my inbox?

谢谢!

推荐答案

b
$ b

Can you try

$access_token = $facebook->getAccessToken();

在调用API之前,请执行类似

And before calling the API do something like

$facebook->setAccessToken($new_access_token);
$facebook->api($page_id.'/conversations', 'GET');

上述应该解决访问令牌问题。但是,由Shankar Damodaran回复,您可以检查他的步骤。

The above should solve the access token issue. However as replied by Shankar Damodaran you may check his steps as well.

此外,您还可以尝试从您的个人资料中删除APP,并尝试进行连接和重试给出权限,看看是否解决问题

Also In addition you can try to remove the APP from your profile and try to do a connect and retry giving permissions and see if this resolves the issue

这篇关于如何使用图形api访问令牌在PHP的Facebook sdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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