Facebook API and OAUTH - permission request before displaying the application

I have the facebook app installed and it works great. What I would like to do is add the functionality of requesting user permission data. such as - read_friendlists, user_groups, email, user_birthday, status_update, publish_stream,

Firstly, here is the code that checks if there is a fan or not a fan in our facebook timeline application.

// If a fan is on your page if ($like_status) { $a = file_get_contents("http://www.domain.com/home.php"); echo ($a); } else { // If a non-fan is on your page $a = file_get_contents("http://www.domain.com/home.php"); echo ($a); } 

What I would like to do is that if there is no fan on our page, open facebook request for permission and set some permissions. Then redirect them to // if there is a fan on our page.

I had a good look, but I still don’t understand how to configure the β€œrequest” on the permission page. Any help would be greatly appreciated.

+3
source share
1 answer

You can do this in two ways.

1) Open the oauth dialog on the page by setting url

 var oauth_url = 'https://www.facebook.com/dialog/oauth/'; oauth_url += '?scope=email,user_birthday,user_location,user_about_me,user_likes'; oauth_url += '&client_id=' + appid; oauth_url += '&redirect_uri=' + encodeURIComponent('https://www.facebook.com/pages/' + appname + '/' + pageId + '/?sk=app_' + appid); window.top.location = oauth_url; 

2) Or you can open the oauth popup:

 FB.login(function(loginResponse) { if (loginResponse.authResponse) { var userId = loginResponse.authResponse.userID; } else { //'User cancelled login or did not fully authorize. } }, { scope: 'email,user_birthday,user_location' }); 
+2
source

All Articles