gpt4 book ai didi

javascript - 如何将 Parse Javascript API 与 Appcelerator 集成而不使用未记录的调用?

转载 作者:IT王子 更新时间:2023-10-29 02:53:28 26 4
gpt4 key购买 nike

我想根据他/她的 Facebook 凭据创建一个用户,而不使用未记录的调用。基于两个已知原因,基于当前的 Parse Javascript 库实现,我认为这是不可能的:

1. 库的当前实现不支持 Appcelerator HTTP 客户端,因此会立即失败。我通过扩展现有的 Parse Javascript 库的 ajax 方法来利用 Appcelerator HTTP 客户端 解决了这个问题。

http://www.clearlyinnovative.com/blog/post/34758524107/parse-appcelerator-titanium-the-easy-way

我创建的幻灯片和博客文章的浏览量大约为 2000 次,所以我很清楚人们希望它起作用。

2. 该库的当前实现假定您正在与 Facebook Javascript 库集成,并且该库也不适用于 Appcelerator。事实上,Appcelerator 已将 Facebook 直接集成到框架中,因此不需要 javascript 库。使用 Appcelerator 开发人员已经熟悉的 API 调用,可以轻松获取将用户帐户链接到 Facebook 所需的所有信息。

原始问题已从 Parse 支持论坛中删除,因此我正在从更广泛的社区中寻找解决方案。

Hi Aaron,

It's not helpful to other developers to promote using undocumented APIs in the Parse library as a workaround, so I make the decision to unlist it. I understand it might help in your particular case with Titanium, and you're well aware of the implications of using private APIs, but other users might overlook that warning. I hope you understand.

Héctor Ramos Solutions Architect, Parse https://parse.com/help

这是太危险而不能在论坛上可见的代码:

// setting auth data retrieved from Ti.Facebook login
authData = {
"facebook" : {
"id" : Ti.Facebook.uid,
"access_token" : Ti.Facebook.accessToken,
"expiration_date" : expDate, // "format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
}
};

// Either way I resolved the problem, calling _handleSaveResult(true) on the returned user object,
// I just dont think it should have been as difficult as it was
// attempt to log the user in using the FB information
var user = new Parse.User();
user.save({
"authData" : authData
}).then(function(_user) {
// force the user to become current
_user._handleSaveResult(true); //<-- this is the evil method I called
if (!_user.existed()) {

// add additional user information
var userInfo = {
"acct_email" : "bryce@xxxxxx.com",
"acct_fname" : "Bryce",
"acct_lname" : "Saunders"
};
return _user.save(userInfo);
}
}).then(function(_user) {

alert('Hooray! Let them use the app now.');

}, function(error) {
alert(' ERROR: ' + JSON.stringify(error, null, 2));
});

Appcelerator论坛上的问题

http://developer.appcelerator.com/question/152146/facebook-appcelerator-and-parse-integration-need-help

Parse 论坛上的问题

https://parse.com/questions/how-do-you-integrate-the-parse-javascript-api-with-appcelerator-and-not-use-undocumented-calls

最佳答案

也许这部分是较新的 SDK,但您不能只调用:

Parse.FacebookUtils.logIn({
"facebook": {
"id": "user's Facebook id number as a string",
"access_token": "an authorized Facebook access token for the user",
"expiration_date": "token expiration date of the format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
},
{
success : function(_user) {},
error : function(_user, error) {}
}
};

它没有记录在 Javascript 指南中,但它记录在代码 visa vie 的未压缩版本中:

@param {String, Object} permissions The permissions required for Facebook
log in. This is a comma-separated string of permissions.
Alternatively, supply a Facebook authData object as described in our
REST API docs if you want to handle getting facebook auth tokens
yourself.

我对您的原始代码进行了一些更新,以支持我将在 Github 上发布的最新 SDK。

非常感谢您带头开展这项工作。您的原始帖子为我节省了数小时。

关于javascript - 如何将 Parse Javascript API 与 Appcelerator 集成而不使用未记录的调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16481751/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com