1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Ghent, Belgium
    Posts
    1
    Vote Rating
    0
    marzsman is on a distinguished road

      0  

    Default Unanswered: Trying to port API call from jQuery to Sencha Touch

    Unanswered: Trying to port API call from jQuery to Sencha Touch


    I developed an app in jQuery mobile that connects to an API with OAuth.
    This works but I'm not completely happy with the performance and some functionality of the framework so I wanted to rebuild the same app in Sencha Touch.

    The code I used to connect with the API in jQuery is this:
    Code:
    function oauthRequestToken() {
        var accessor = { consumerSecret: $.consumerSecret
            , tokenSecret: null };
        var message = { action: $.apiUrl + 'oauth/request_token'
            , method: 'GET'
            , parameters: { oauth_consumer_key: $.consumerKey
                , oauth_signature_method: $.signatureMethod }
        };
        OAuth.setTimestampAndNonce(message);
        OAuth.SignatureMethod.sign(message, accessor);
        var parameters = OAuth.getParameterMap(message.parameters);
        $.get(message.action, parameters, function(data) {
            console.log(JSON.stringify(data));
        });
    }
    I ported this function to Sencha like this:
    Code:
    function oauthRequestToken() {
        var accessor = { consumerSecret: config.consumerSecret
            , tokenSecret: null };
        var message = { action: config.apiUrl + 'oauth/request_token'
            , method: 'GET'
            , parameters: { oauth_consumer_key: config.consumerKey
                , oauth_signature_method: config.signatureMethod }
        };
        OAuth.setTimestampAndNonce(message);
        OAuth.SignatureMethod.sign(message, accessor);
        var parameters = OAuth.getParameterMap(message.parameters);
        Ext.Ajax.request({
            url: message.action,
            params: parameters,
            method: 'GET',
            success: function(response, opts) {
                data = Ext.decode(response.responseText);
                
                console.log(JSON.stringify(data));
            }
        });
    }
    It's almost exact the same code, except for the variables. The biggest difference is the "Ext.Ajax.request" call to the API.

    The problem is that with the Sencha version I always get the error returned that my signature is not correct. I compared the 2 url's and I can't see any differences.

    Can anyone tell me what I'm doing wrong? Do I have to use something else then Ext.Ajax.request to do a call to the API?

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    57
    Vote Rating
    0
    NCN is on a distinguished road

      0  

    Default


    Even I need to do the same.

    have you completed your API call from the jqury to sench touch. If you completed the task.
    Please share the code in zip file

    Thahnk in advance.

Thread Participants: 1

Tags for this Thread