如何为没有应用程序或应用程序机密的页面获取 Facebook 访问令牌 [英] How to get a Facebook access token for a page with no app or app secret

查看:19
本文介绍了如何为没有应用程序或应用程序机密的页面获取 Facebook 访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自动显示来自另一个网站的 Facebook 页面的墙贴.我可以使用 Graph API explorer 来手动获取.当我在我的代码中使用生成的令牌时,一切都很好.问题是令牌很快过期.每天多次获得新代码是不切实际的.我知道有一种方法可以以编程方式请求访问令牌 - 在我的例子中是通过 PHP,但所有示例都需要一个应用程序机密.由于这是一个页面而不是一个应用程序,因此没有秘密.

I am trying to automatically display wall posts from a Facebook page another website. I can use the Graph API explorer to get one manually. When I use the generated token in my code all is well. The problem is the tokens expire quickly. It just isn't practical to get a new code several times a day. I know there is a way to request an access token programatically - in my case via PHP, but all the examples call for an app secret. Since this is a page and not an app, there is no secret.

我已经试过了:

https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=MY_CLIENT_ID&redirect_uri=http%3A%2F%2FMY_SITE_URL&scope=user_status

我得到的是这个:

{错误": {"message": "验证应用程序时出错.由于系统错误,无法获取应用程序信息.","type": "OAuthException",代码":101}}

{ "error": { "message": "Error validating application. Cannot get application info due to a system error.", "type": "OAuthException", "code": 101 } }

我曾尝试使用 Fiddler 拦截来自 Graph API 资源管理器的调用,以查看我的代码文件中需要什么,但没有任何运气.

I have tried using Fiddler to intercept the call from the Graph API explorer to see what I need in my code file, but haven't had any luck.

推荐答案

对于非私有(公共)的图形对象,您可以使用您的 app_id 作为 access_token.

For graph objects that are not private (public) you can use your app_id as an access_token.

您的 app_id 永远不会改变,因此您无需更新.问题是墙上的内容是你的吗?

Your app_id never changes so you don't ever have to renew it. The question is is the wall content yours?

如果是这样,您可以轻松地使用您的 app_id 来完成此操作,而无需每次都请求访问令牌.

If so you can easily use your app_id to accomplish this without having to request an access token everytime.

但是,为了拥有 app_id,您需要使用 facebook 开发者帐户在 facebook 上创建一个应用程序.据我所知,没有办法匿名向 Graph API 发出请求,

However, in order to have an app_id you need to create an application on facebook with a facebook developer account. As far as I understand there isnt a way to anonymously make request to the Graph API,

这篇关于如何为没有应用程序或应用程序机密的页面获取 Facebook 访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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