有没有任何Facebook插件的phonegap 2.7.0? [英] Is there any Facebook plugin for phonegap 2.7.0?
问题描述
是否有任何适用于Phonegap 2.7.0的Facebook插件?
当我们尝试下面的一个,我们最终会在Phonegap 2.7.0上出现不推荐的错误。 / p>
https ://github.com/phonegap/phonegap-facebook-plugin/blob/master/README.md
我们在Google上找不到任何东西
谢谢,
Sid
我建议您使用手机插槽随附的inappbrowser插件来执行此操作。
请填写以下xxx相关信息
var my_client_id =xxxxxx,//您的APP ID
my_secret =xxxxxxxxx,//您的APP SECRET
my_redirect_uri =https://www.facebook.com/connect/login_success.html,// LEAVE THIS
my_type =user_agent ,my_display =touch; // LEAVE THIS
var facebook_token =fbToken; //我们的KKERPER
var ref; // IN APP BROWSER REFERENCE
// FACEBOOK
var Facebook = {
init:function(){
//开始授权
var authorize_url = https://www.facebook.com/dialog/oauth?;
authorize_url + =client_id =+ my_client_id;
authorize_url + =& redirect_uri =+ my_redirect_uri;
authorize_url + =& display =+ my_display;
authorize_url + =& scope = publish_stream;
//通过LINK调用APP BROWSER
ref = window.open(authorize_url,'_blank','location = no');
ref.addEventListener('loadstart',function(event){
Facebook.facebookLocChanged(event.url);
});
},
facebookLocChanged:function(loc){
if(loc.indexOf(code =)> = 1){
//关闭INAPPBROWSER和NAVIGATE TO INDEX
ref.close();
//这是要在服务器端保护客户端秘密
var codeUrl ='https://graph.facebook.com/oauth/access_token?client_id='+my_client_id+ '&安培; client_secret =' + my_secret + '&安培; REDIRECT_URI =' + my_redirect_uri + '&安培;码=' + loc.split( =)[1];
console.log('CODE_URL ::'+ codeUrl);
$ .ajax({
url:codeUrl,
data:{},
type:'POST',
async:false,
cache: false,
success:function(data,status){
// WE STORE THE TOKEN HERE
localStorage.setItem(facebook_token,data.split('=')[1] .split '&')[0]);
},
错误:function(){
alert(未知错误发生);
}
}) ;
}
}
我将添加更多的注销功能和发布到墙壁等
您可以在不推荐使用者这里找到文档
Is there any Facebook plugin for Phonegap 2.7.0?
When we try the below one, we are end up with deprecated error on Phonegap 2.7.0.
https://github.com/phonegap/phonegap-facebook-plugin/blob/master/README.md
We couldn't find anything when we Google it.
Thank you,
Sid
I would suggest you use the inappbrowser plugin that comes with phonegap to do this .. example shown below. Fill in the xxx below with your relevant info
var my_client_id = "xxxxxx", // YOUR APP ID
my_secret = "xxxxxxxxx", // YOUR APP SECRET
my_redirect_uri = "https://www.facebook.com/connect/login_success.html", // LEAVE THIS
my_type ="user_agent", my_display = "touch"; // LEAVE THIS
var facebook_token = "fbToken"; // OUR TOKEN KEEPER
var ref; //IN APP BROWSER REFERENCE
// FACEBOOK
var Facebook = {
init:function(){
// Begin Authorization
var authorize_url = "https://www.facebook.com/dialog/oauth?";
authorize_url += "client_id=" + my_client_id;
authorize_url += "&redirect_uri=" + my_redirect_uri;
authorize_url += "&display=" + my_display;
authorize_url += "&scope=publish_stream";
//CALL IN APP BROWSER WITH THE LINK
ref = window.open(authorize_url, '_blank', 'location=no');
ref.addEventListener('loadstart', function(event){
Facebook.facebookLocChanged(event.url);
});
},
facebookLocChanged:function(loc){
if (loc.indexOf("code=") >= 1 ) {
//CLOSE INAPPBROWSER AND NAVIGATE TO INDEX
ref.close();
//THIS IS MEANT TO BE DONE ON SERVER SIDE TO PROTECT CLIENT SECRET
var codeUrl = 'https://graph.facebook.com/oauth/access_token?client_id='+my_client_id+'&client_secret='+my_secret+'&redirect_uri='+my_redirect_uri+'&code='+loc.split("=")[1];
console.log('CODE_URL::' + codeUrl);
$.ajax({
url: codeUrl,
data: {},
type: 'POST',
async: false,
cache: false,
success: function(data, status){
//WE STORE THE TOKEN HERE
localStorage.setItem(facebook_token, data.split('=')[1].split('&')[0]);
},
error: function(){
alert("Unknown error Occured");
}
});
}
}
I would add more functions for logout and posting to a wall etc. You can find documenatation on the inappbrowser here
这篇关于有没有任何Facebook插件的phonegap 2.7.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!