[英]How do you integrate the Parse Javascript API with Appcelerator and not use undocumented calls?
我想從他/她的Facebook憑據創建一個用戶,而不使用未記錄的調用。 基於兩個已知原因,我認為基於Parse Javascript庫的當前實現是不可能的:
1.庫的當前實現不支持Appcelerator HTTP客戶端,因此它立即失敗。 我通過擴展現有的Parse Javascript庫的ajax方法來利用Appcelerator HTTP client
解決了這個問題。
http://www.clearlyinnovative.com/blog/post/34758524107/parse-appcelerator-titanium-the-easy-way
在我創建的幻燈片上有大約2K的視圖,在博客文章中大致相同,所以我很清楚人們希望這個工作。
2.庫的當前實現假設您正在與Facebook Javascript庫集成,並且該庫也不能與Appcelerator一起使用。 事實上,Appcelerator已將Facebook直接集成到框架中,因此不需要javascript庫。 使用Appcelerator開發人員熟悉的API調用可以輕松獲得將用戶帳戶鏈接到Facebook所需的所有信息。
原始問題已從Parse支持論壇中刪除,因此我正在尋找更廣泛社區的解決方案。
嗨,亞倫,
對於其他開發人員來說,在Parse庫中推廣使用未記錄的API作為解決方法是沒有幫助的,因此我決定將其取消列表。 我知道它可能對您使用Titanium的特定情況有所幫助,並且您很清楚使用私有API的含義,但其他用戶可能會忽略該警告。 我希望你明白。
HéctorRamosSolutions 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論壇的問題
關於解析論壇的問題
也許這是較新的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指南中記錄,但它在代碼簽證的未經授權的版本中記錄:
@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。
非常感謝能夠帶頭開展這項工作。 您的原始帖子節省了我幾個小時
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.