开发者

Extend Facebook permissions

I need a new permission for my application.

How can I extend开发者_Python百科 (reask) permissions?

Thanks!


This isn't possible programmatically.

User has to "delete" that application from his privacy settings and retry again


Replace app_id, url of your app main script and add needed permissions (scope). Then place this string to browser and press Enter ;) https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream


You can do it using Facebook Javascript SDK too:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_EN/all.js"></script>
<script>
FB.init({
    appId  : 'your app id',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
});
</script>

<script>
function askPermission() {
    FB.login(function(response) {
        if (response.session) {
            /* New permissions granted */
            var newAccessToken = response.session.access_token;
        }
    }, {perms:'email'});
}
</script>


my application was asking for basic permission first then i changed it to ask for extended using below code in php:

  $facebook = new Facebook(array(
      'appId'  => 'xxxxxxxxxxxxxxxxxx',
      'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    ));
    $user = $facebook->getUser();
    $user_profile = $facebook->api('/me');


    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!'));
                      $post_id = $facebook->api('/me/feed', 'post', $attachment);

                } else {
                    // We don't have the permission
                    // Alert the user or ask for the permission!
                    echo "Click Below to Enter!";
                    header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream")) );
                }

the else part asks for permission if user hasn't granted extended permission yet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜