有没有办法检查用户是否已在服务器端授予给定权限?
我需要检查用户是否已在服务器端授予给定权限(例如:publish_stream)。它适合客户端存在的解决方案,但我需要的是服务器端的。
有什么想法吗?
I need to check if user has granted a given permission (for example: publish_stream) in server-side. It seams for client-side exists solution but what I need is for server-side.
Any idea please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要一个服务器端 API,例如 Facebook Java API 或 restFB。这些是 java API(我已经使用过),还有许多其他适用于不同语言的 API。官方的信息显示在 Facebook 开发者门户上。
使用这些 API,您将能够做的不仅仅是在服务器端验证用户身份。点击链接到不同的页面,您会发现一些片段,可以帮助您立即开始!
编辑
由于您使用的是 ASP,因此您需要 ASP .NET API。这是通过 Google 搜索 http://facebooksdk.codeplex.com/ 找到的第一个结果。
使用此 API 和 MVC 架构,您可以使用诸如
[CanvasAuthorize(Perms = "publish_stream")]
之类的内容来注释包含需要权限的代码的任何控制器操作,并且当用户调用该操作时,它们需要提供许可。我无法提供更多详细信息,因为我从未使用过此 API,但请深入查看 构建示例应用程序的教程。
You need a server side API like the Facebook Java API or restFB. These are java APIs (that I have used), there a host of others for different languages. The official ones are shown on the Facebook developer portal.
Using these APIs you will be able to do more than just authenticate a user on the server side. Follow the link to the different pages and you'll find snippets that will get you started in no time!
EDIT
Since you're using ASP, you'll need an ASP .NET API. This is the first result found from a google search http://facebooksdk.codeplex.com/ .
Using this API and an MVC architecture, you are able to annotate any controller actions that contain code that requires permissions with something like
[CanvasAuthorize(Perms = "publish_stream")]
and when the user calls that action they'll need to provide permission.I cant give more details as I've never used this API but do check out this in-depth tutorial on building a sample application.
您可以对此 URL 进行 Graph API 调用 https://graph.facebook.com/me/permissions 包括用户访问令牌。您将获得用户权限的结果。有关更多详细信息,请参阅 https://developers.facebook.com/docs/reference/api/用户/
You can make a Graph API call to this URL https://graph.facebook.com/me/permissions including the user access token. You will get results with the user's permissions. For more details see https://developers.facebook.com/docs/reference/api/user/
解决方案:
步骤1.首先你必须进行查询:
查询类似于:
SELECT {0} FROM requests WHERE uid = {1}
{0} 是逗号分隔的权限。例如:
publish_stream,offline_access
{1} 是 userId
步骤 2. 然后将此查询发送到给定的 url:
url:
https://api.facebook.com/method/fql.query ?query={0}&format=JSON&access_token={1}
{0} 是我们在步骤 1 中进行的查询
{1} 是用户的 AccessToken
示例结果:
[{"publish_stream":1,"offline_access":0}]
更新使用 Graph Api 的另一种方式:
https://graph.facebook.com/ me/permissions?access_token={0}
{0} 是用户的 AccessToken
示例结果:
{
"data": [
]
}
Solution:
Step 1. First u must make a query:
query is like:
SELECT {0} FROM permissions WHERE uid = {1}
{0} is comma-separated permissions. for example:
publish_stream,offline_access
{1} is userId
Step 2. Then send this query to the given url:
url:
https://api.facebook.com/method/fql.query?query={0}&format=JSON&access_token={1}
{0} is query that we made in step1
{1} is user's AccessToken
Sample Result:
[{"publish_stream":1,"offline_access":0}]
Update Another way with using Graph Api:
https://graph.facebook.com/me/permissions?access_token={0}
{0} is user's AccessToken
Sample Result:
{
"data": [
]
}