Facebook API& OAUTH - 显示应用程序前的请求权限 [英] Facebook API & OAUTH - Request Permission before displaying app

查看:105
本文介绍了Facebook API& OAUTH - 显示应用程序前的请求权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了一个Facebook应用程序,工作很棒。
我想做的是增加请求用户权限数据的功能。
,如 - read_friendlists,user_groups,email,user_birthday,status_update,publish_stream,



首先这是代码,检查一个粉丝或没有粉丝在我们的Facebook时间轴应用程序

  //如果您的页面上有粉丝
if($ like_status){
$ a =的file_get_contents( http://www.domain.com/home.php);
echo($ a);
}
else {
//如果非粉丝在您的页面上
$ a = file_get_contents(http://www.domain.com/home.php );
echo($ a);
}

我想做什么,是,如果没有一个粉丝在我们的页面,打开Facebook请求的权限并设置一些权限。然后将它们重定向到//如果一个粉丝在我们的页面上。



我在这里看了很多,但我仍然不清楚如何设置请求权限页面。
任何帮助将不胜感激

解决方案

您可以通过两种方式执行此操作。



1)通过设置网址打开oauth对话框

  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)或者您可以在弹出窗口中打开oauth对话框:

  FB.login(function(loginResponse){
if(loginResponse.authResponse){
var userId = loginResponse.authResponse.userID;
}
else {
//'用户取消登录或没有完全授权
}
},{scope:'email,user_birthday,user_location'});


I have a facebook app installed and working great. What I would like to do is add in 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 a fan or none fan is on our facebook timeline app.

// 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, if a none fan is on our page, open a facebook request for permission and set a number of permissions. Then redirect them to the // if a fan is on our page.

I have had a good look around here but I am still not clear how to setup the "request" for permission page. Any help would be greatly appreciated

解决方案

you can do this in two ways..

1) Open oauth dialog in page by setting the 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 dialog in 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' });

这篇关于Facebook API& OAUTH - 显示应用程序前的请求权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆