我正在尝试让 Parse.FacebookUtils.logIn 在 Ionic View 上工作,当我在浏览器中点击 ionic serve 时,我已经成功地让它工作,但问题是当我尝试使用 Ionic 登录时查看模拟器,基本上不会弹出身份验证 Facebook 窗口,我不知道为什么。
我遵循了这个文档: https://www.parse.com/docs/js/guide#users-facebook-users
一切都在浏览器中运行良好,只是试图使其在 Ionic View 中运行。
有什么想法吗?
最佳答案
我放弃了使用 Ionic 的 Parse sdk 并开始使用另一个使用以下文档的插件:
http://ngcordova.com/docs/plugins/oauth/
https://github.com/nraboy/ng-cordova-facebook-example/blob/master/www/js/app.js
这是我为使其与 Parse 一起工作而编写的代码:
$scope.fbLogin = function() {
var result;
$cordovaOauth.facebook('987971754588010', ['public_profile, user_birthday, email']).then(function(success) {
$http.get("https://graph.facebook.com/v2.2/me", { params: { access_token: success.access_token, fields: "id,name,birthday,last_name,first_name,email,gender,picture.type(large)", format: "json" }}).then(function(result) {
$localstorage.setObject('fbData', result.data);
var expiration_date = new Date();
expiration_date.setSeconds(expiration_date.getSeconds() + success.expires_in);
expiration_date = expiration_date.toISOString();
var facebookAuthData = {
"id": result.data.id,
"access_token": success.access_token,
"expiration_date": expiration_date
};
Parse.FacebookUtils.logIn(facebookAuthData, {
success: function(user) {
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
$scope.openModal();
} else {
alert("User logged in through Facebook!");
$scope.syncFbData(null);
}
},
error: function(user, error) {
console.log('ERROR: ' + error);
var alertPopup = $ionicPopup.alert({
title: 'Error de autenticación de usuario',
template: 'El usuario canceló autenticación con Facebook o no autorizó permisos. '
});
}
});
}, function(error) {
console.log('ERROR: ' + error);
var alertPopup = $ionicPopup.alert({
title: 'Error de conexión',
template: 'No se ha logrado establecer conexión con Facebook.'
});
});
}, function(error) {
console.log('ERROR: ' + error);
var alertPopup = $ionicPopup.alert({
title: 'Error de conexión',
template: 'No se ha logrado establecer conexión con Facebook.'
});
});
};
$scope.syncFbData = function (newUsername) {
var fbData = $localstorage.getObject('fbData')
var currentUser = Parse.User.current();
if (newUsername) {
currentUser.set('username', newUsername);
}
currentUser.set('nombre', fbData.first_name);
currentUser.set('apellidos', fbData.last_name);
currentUser.set('email',fbData.email);
currentUser.set('fechaNacimiento', new Date(fbData.birthday));
currentUser.set('imagenUrl',fbData.picture.data.url);
currentUser.set('genero',((fbData.gender === 'male') ? 'Hombre' : 'Mujer') );
currentUser.save(null, {
success: function (response) {
$scope.closeModal();
$state.go('app.lista-cervezas');
},
error: function (response, error) {
console.log('ERROR: ' + error);
var alertPopup = $ionicPopup.alert({
title: 'Nombre de usuario invalido',
template: 'El nombre de usuario ingresado ya se encuentra en uso!'
});
}
});
};
关于javascript - 解析 Facebook 登录在 ionic View 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33600172/
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在使用ruby1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我有一个rubyonrails应用程序。我按照facebook的说明添加了一个像素。但是,要跟踪转化,Facebook要求您将页面置于达到预期结果时出现的转化中。即,如果我想显示客户已注册,我会将您注册后转到的页面作为成功对象进行跟踪。我的问题是,当客户注册时,在我的应用程序中没有登陆页面。该应用程序将用户带回主页。它在主页上显示了一条消息,所以我想看看是否有一种方法可以跟踪来自Controller操作而不是实际页面的转化。我需要计数的Action没有页面,它们是ControllerAction。是否有任何人都知道的关于如何执行此操作的gem、文档或最佳实践?这是进入布局文件的像素
简而言之错误:NOTE:Gem::SourceIndex#add_specisdeprecated,useSpecification.add_spec.Itwillberemovedonorafter2011-11-01.Gem::SourceIndex#add_speccalledfrom/opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91./opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/gem_dependency.rb:275:in`==':und
我正在使用ruby2.1.0我有一个json文件。例如:test.json{"item":[{"apple":1},{"banana":2}]}用YAML.load加载这个文件安全吗?YAML.load(File.read('test.json'))我正在尝试加载一个json或yaml格式的文件。 最佳答案 YAML可以加载JSONYAML.load('{"something":"test","other":4}')=>{"something"=>"test","other"=>4}JSON将无法加载YAML。JSON.load("
我试图在我的网站上实现使用Facebook登录功能,但在尝试从Facebook取回访问token时遇到障碍。这是我的代码:ifparams[:error_reason]=="user_denied"thenflash[:error]="TologinwithFacebook,youmustclick'Allow'toletthesiteaccessyourinformation"redirect_to:loginelsifparams[:code]thentoken_uri=URI.parse("https://graph.facebook.com/oauth/access_token
我想用Nokogiri解析HTML页面。页面的一部分有一个表,它没有使用任何特定的ID。是否可以提取如下内容:Today,3,455,34Today,1,1300,3664Today,10,100000,3444,Yesterday,3454,5656,3Yesterday,3545,1000,10Yesterday,3411,36223,15来自这个HTML:TodayYesterdayQntySizeLengthLengthSizeQnty345534345456563113003664354510001010100000344434113622315