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

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

问题描述

我正试图从Facebook页面自动显示墙上的其他网站。我可以使用Graph API Explorer来手动获取。当我在代码中使用生成的令牌一切都很好。问题是令牌快速到期。每天多次获取新代码是不实际的。我知道有一种方式可以通过PHP方式请求访问令牌 - 在我的情况下,通过PHP,但所有的示例都要求一个应用程序的秘密。因为这是一个页面而不是一个应用程序,所以没有秘密。



我已经尝试过:



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



我收到的是这样的:



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


$ b $我尝试使用Fiddler截取Graph API资源管理器中的调用,以查看我在代码文件中需要什么,但没有任何运气。

解决方案

对于非私有(public)的图形对象,可以使用app_id作为access_token。



您的app_id不会更改,因此您不必更新它。问题是你的墙壁内容?



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

但是,为了拥有一个app_id,您需要在Facebook上使用Facebook开发者帐户创建一个应用程序。据我所知,没有一种匿名方式向Graph API请求,


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.

I have tried this:

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

What I get back is this:

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

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.

解决方案

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

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

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

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天全站免登陆