简体   繁体   English

如何使用Facebook图形API的用户访问令牌? (PHP)

[英]How do I use an user access token to with the Facebook graph api? (PHP)

I don't have any issue getting my access token: 获取访问令牌时没有任何问题:

$accessToken = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=$appID&client_secret=$appSecret&grant_type=client_credentials");

But I seem to be missing part of the core concept of how to use it. 但我似乎忽略了如何使用它的核心概念的一部分。 For example, when I request: 例如,当我请求时:

$jsonString = file_get_contents("https://graph.facebook.com/cocacola/statuses?access_token=$accessToken");

(And yeah, I'm stripping out the "access_token=" part in between the two lines, the URL is good) (是的,我正在剥离两行之间的“access_token =”部分,URL很好)

I get this back: 我得到了回报:

{
   "error": {
  "message": "A user access token is required to request this resource.",
  "type": "OAuthException",
  "code": 102
  }
}

I'm a bit confused as to what I'm missing here. 我对这里缺少的东西感到有点困惑。 I know with people you need them to authorize it, but this is just a page with public statuses. 我知道你需要他们授权的人,但这只是一个公共状态的页面。

That's an app access token you're using - to make calls on behalf of a user you need them to authorise your app using the Authentication flows in the documentation 这是您正在使用的应用访问令牌 - 代表您需要的用户拨打电话,使用文档中的身份验证流程来授权您的应用

An app access token (which you get from the client_credentials call above) should give you completely public posts, but many pages are demographically restricted, or the posts themselves are targeted only at certain countries, in which case you need a user access token to retrieve them 应用程序访问令牌(您从上面的client_credentials调用获得)应该为您提供完全公开的帖子,但许多页面受人口统计限制,或者帖子本身仅针对特定国家/地区,在这种情况下您需要用户访问令牌来检索他们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM