如何将解析Javascript API与Appcelerator集成,而不使用未文档化的调用?

时间:2022-04-16 06:36:53

I would like to create a user from his/her Facebook credentials without using undocumented calls. I do not believe it is possible based on the current implementation of Parse Javascript Library for two known reasons:

我想从他/她的Facebook凭证中创建一个用户,而不使用未注册的调用。我不认为基于当前解析Javascript库的实现是可能的,原因有两个:

1. The current implementation of the library does not support the Appcelerator HTTP client so it fails immediately. I have addressed this issue by extending the existing Parse Javascript library's ajax method to utilize the Appcelerator HTTP client.

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

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

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

There has been approximately 2K views on the slide deck I created and about the same on the blog post, so it is pretty clear to me people want this to work.

在我创建的幻灯片上有大约2K个视图,在博客上也有差不多的视图,所以我很清楚,人们希望它能工作。

2. The current implementation of the library assumes you are integrating with the Facebook Javascript library and that library does not work with Appcelerator either. In fact Appcelerator has integrated Facebook directly into the framework so there is no need for the javascript library. All of the information required to link a user account to Facebook can be easily gotten using the API calls that Appcelerator developers are already familiar with.

2。库的当前实现假设您正在与Facebook Javascript库集成,该库也不能与Appcelerator兼容。实际上,Appcelerator直接将Facebook集成到了框架中,因此不需要javascript库。通过Appcelerator开发人员已经熟悉的API调用,可以很容易地获得将用户帐户链接到Facebook所需的所有信息。

The original question was removed from the Parse Support forum so I am looking for a solution from a wider community.

最初的问题已经从解析支持论坛中删除,因此我正在寻找一个来自更广泛社区的解决方案。

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.

对于其他开发人员来说,在解析库中使用未归档的api作为解决方案是没有用的,所以我决定将其取消。我知道这可能对您使用Titanium的情况有所帮助,您也很清楚使用私有api的含义,但是其他用户可能会忽略这个警告。我希望你理解。

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

Hector Ramos解决方案架构师,解析https://parse.com/help

This is the code that was too dangerous to be left visible on the forum:

这是过于危险而不能在论坛上看到的守则:

// 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));
});

Question on Appcelerator Forum

问题在Appcelerator论坛

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

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

Question on Parse Forum

问题解析论坛

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

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

1 个解决方案

#1


3  

Maybe this part of a newer SDK, but can't you just call:

也许这是新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) {}
   }
};

It's not documented in the Javascript guide, but it is documented in the unminified version of the code visa vie:

它没有在Javascript指南中被记录,但是它被记录在代码签证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.

I made some updates to your original code to support the lastest SDK which I'm going to publish on Github.

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

Thanks so much for spearheading this effort. Your original post saved me hours.

非常感谢您带头进行这项工作。你原来的帖子帮我省了几个小时。

#1


3  

Maybe this part of a newer SDK, but can't you just call:

也许这是新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) {}
   }
};

It's not documented in the Javascript guide, but it is documented in the unminified version of the code visa vie:

它没有在Javascript指南中被记录,但是它被记录在代码签证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.

I made some updates to your original code to support the lastest SDK which I'm going to publish on Github.

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

Thanks so much for spearheading this effort. Your original post saved me hours.

非常感谢您带头进行这项工作。你原来的帖子帮我省了几个小时。