Php 在FB.ui中,方法权限为。请求重定向uri工作不正常

Php 在FB.ui中,方法权限为。请求重定向uri工作不正常,php,facebook,iframe,fbjs,facebook-php-sdk,Php,Facebook,Iframe,Fbjs,Facebook Php Sdk,嗨,我最近修改了我的应用程序,它只需要基本信息。来自用户的权限,但现在我也需要流发布权限。因此,我在我的索引页上检查,如果用户未被授予流发布权限,我只会显示以下权限对话框: <?php $permission = $facebook->api(array('method' => 'users.hasAppPermission','ext_perm'=>'publish_stream','uid'=> $uid)); if($permission != '1

嗨,我最近修改了我的应用程序,它只需要基本信息。来自用户的权限,但现在我也需要流发布权限。因此,我在我的索引页上检查,如果用户未被授予流发布权限,我只会显示以下权限对话框:

<?php $permission = $facebook->api(array('method' =>   'users.hasAppPermission','ext_perm'=>'publish_stream','uid'=> $uid));
   if($permission != '1')
   {
    echo "<script type='text/javascript'>

                var dialog = {
                    method: 'permissions.request',
                    perms: 'publish_stream'
                };  

            FB.ui(dialog,null);
        </script>";
   }
?>
但它仍然不起作用

请帮助我如何解决此问题。

请尝试以下方法:

<?php
$loginUrl = $facebook->getLoginUrl(array(
    "scope" => "publish_stream",
    "redirect_uri" => "http://apps.facebook.com/xyz"
));

$isGranted = $facebook->api(array(
    "method"    => "users.hasAppPermission",
    "ext_perm"   => "publish_stream",
    "uid"       => $uid /* The user ID of the user whose permissions
                         * you are checking. If this parameter is not
                         * specified, then it defaults to the session user.
                         */
));
if($isGranted !== "1")
    echo("<script> top.location.href='" . $loginUrl . "'</script>");
?>
请尝试以下方法:

<?php
$loginUrl = $facebook->getLoginUrl(array(
    "scope" => "publish_stream",
    "redirect_uri" => "http://apps.facebook.com/xyz"
));

$isGranted = $facebook->api(array(
    "method"    => "users.hasAppPermission",
    "ext_perm"   => "publish_stream",
    "uid"       => $uid /* The user ID of the user whose permissions
                         * you are checking. If this parameter is not
                         * specified, then it defaults to the session user.
                         */
));
if($isGranted !== "1")
    echo("<script> top.location.href='" . $loginUrl . "'</script>");
?>
$permissions = $facebook->api("/me/permissions");
if( array_key_exists('publish_stream', $permissions['data'][0]) ) {
    // Permission is granted!
    // Do the related task
    $post_id = $facebook->api('/me/feed', 'post', array('message'=>'Hello World!'));
} else {
    // We don't have the permission
    // Alert the user or ask for the permission!
    header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream")) );
}