如何检查 Facebook 的特殊权限

发布于 2024-08-07 21:00:21 字数 52 浏览 4 评论 0原文

我如何检查 JavaScript 用户是否已授予我的网站发布流权限

how can i check in javascript
if user has granted my site the publish stream permission

?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

从来不烧饼 2024-08-14 21:00:21

我遇到了同样的问题,但找不到任何示例代码。无论如何,我想出了这个,这对我有用。希望这对某人有帮助。

FB.api('/me/permissions', function (response) {
            var perms = response.data[0];

            if (perms.publish_stream) {                
                // User has permission
            } else {                
                // User DOESN'T have permission
            }                                            
    } );

I had this same problem but couldn't find any sample code. Anyways, I came up with this, which works for me. Hope this helps someone.

FB.api('/me/permissions', function (response) {
            var perms = response.data[0];

            if (perms.publish_stream) {                
                // User has permission
            } else {                
                // User DOESN'T have permission
            }                                            
    } );
拿命拼未来 2024-08-14 21:00:21

您要查找的 API 方法是 Users.hasAppPermission。您可以直接从 JavaScript 调用它,但编写自己的 HTTP 方法可能会更有效,该方法通过 API 调用它并通过 JSON 返回“true”或“false”。

还有一个已提交的错误 (13378) Users.hasAppPermission 没有等效的 Graph API。

The API method you're looking for is Users.hasAppPermission. You could call it directly from JavaScript, but it will probably be more efficient to write your own HTTP method, that calls it via API and returns "true" or "false" via JSON.

There is also a filed bug (13378) that Users.hasAppPermission has no Graph API equivalent.

马蹄踏│碎落叶 2024-08-14 21:00:21

在新的 Graph API(包括通过 JavaScript)中,这可以通过访问“/[user]/permissions”来完成。

来自用户对象文档

权限

用户授予应用程序的权限。

array 包含单个对象,该对象具有密钥作为权限
名称和值作为权限值 (1/0) - 权限
默认情况下,值 0 从对象中省略;还包括一个类型
字段始终为权限

In the new Graph API (including via JavaScript) this can be accomplished by accessing "/[user]/permissions".

From the User object documentation:

permissions

The permissions that user has granted the application.

array containing a single object which has the keys as the permission
names and the values as the permission values (1/0) - Permissions with
value 0 are omitted from the object by default; also includes a type
field which is always permissions.

葵雨 2024-08-14 21:00:21

貌似不支持。至少没有记录

不过,一旦获得许可,您就可以从 javascript 中读取内容。

Looks like is not supported. At least is not documented.

You may read from javascript once the permission is granted though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文