如何检查用户是否已经授予我的PHP应用程序的一定权限? [英] How to check if a user has granted a certain set of permissions to my PHP app?
本文介绍了如何检查用户是否已经授予我的PHP应用程序的一定权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据,有没有办法检查用户是否已经使用基于PHP的Facebook SDK向应用程序授予了一定的权限?
我浏览过API,但找不到任何东西。
Based on this question, is there a way to check if a user has granted a certain set of permissions to an app using PHP based Facebook SDK? I've browsed the API but couldn't find anything.
推荐答案
$permissions = $facebook->api("/me/permissions");
然后使用if来检查你需要的权限
then use the if to check which permission you need
EX:
if (array_key_exists('publish_stream', $permissions['data'][0])) {
postToWall();
} else {
//Does not have permission
}
如果您正在使用FQL
If you are using FQL
$perms = $facebook->api(array(
"method" => "fql.query",
"query" => "SELECT read_stream,offline_access,publish_stream FROM permissions WHERE uid=me()"
));
echo "<ul>";
foreach ($perms[0] as $k => $v) {
echo "<li>";
if ($v === "1") {
echo "<strong>$k</strong> permission is granted.";
} else {
echo "<strong>$k</strong> permission is not granted.";
}
echo "</li>";
}
这篇关于如何检查用户是否已经授予我的PHP应用程序的一定权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文