Page 1 of 1

Using Twitter tutorial to call standard Geo search for twitter

Posted: Mon Jan 27, 2014 10:01 pm
by araskin3i

Hi,

I am using http://docs.appery.io/tutorials/build... to call the Geo Search Twitter API (https://dev.twitter.com/docs/api/1.1/...).

I understand from the tutrial that all calls to the Twitter API must have the AUTHORIZATION header in it or it will fail. I understand that when this header is created a special signature is appended based on the URL and parameters being passed in. The parameters that I am passing in are lat, long and accuracy. However I am not really clear how I am supposed to call EncodeHelper.getHeader for each of those params.

What I did was bind in each of the UI elements that contain lat, long and accuracy into the Authorization header and then I created a 'transform' JS function which calls EncodeHelper.getHeader. However, I expected this to be called once for each param but it only seems to get called once.

The Appery proxy is returning java.lang.ArrayIndexOutOfBoundsException error and I am not sure what I have done wrong.

Have I gone about this the wrong way?


Using Twitter tutorial to call standard Geo search for twitter

Posted: Mon Jan 27, 2014 11:27 pm
by Alena Prykhodko

Hi,

Please show us a screen shot of mapping. Also post the code you use.


Using Twitter tutorial to call standard Geo search for twitter

Posted: Tue Jan 28, 2014 2:23 pm
by araskin3i

Image

OK the mapping is above. As you can see I am mapping in lat, long and accuracy. The problem is that as per the tutorial I am supposed to call the following code to create the Authorization header.

code
var authorization = EncodeHelper.getHeader('https://api.twitter.com/1.1/geo/search.json', {status: value});
return authorization;
/code

Problem is I am not sure how I am supposed to encode that header for 3 parameters since I dont have the value.


Using Twitter tutorial to call standard Geo search for twitter

Posted: Tue Jan 28, 2014 2:26 pm
by araskin3i

OOops i realized that the code above is wrong. I should be calling

code
var authorization = EncodeHelper.getHeader('https://api.twitter.com/1.1/geo/search.json', {status: value});
return authorization;
/code

but I am still not sure how I can pass in all 3 parameters into the call above...


Using Twitter tutorial to call standard Geo search for twitter

Posted: Tue Jan 28, 2014 2:39 pm
by araskin3i

OK Never mind I have worked it out.

I ended just passing in the Authorization header using code

code
var latValue = Appery("labelLat").text();
var longValue = Appery("labelLong").text();
var accVal = Appery("labelAccuracy").text();

var authorizationHeader = EncodeHelper.getHeader('https://api.twitter.com/1.1/geo/search.json', {lat: latValue, long: longValue, accuracy: accVal});

serviceTwitterPOIGet.execute({data: {"Authorization": authorizationHeader }});
/code

Thanks for offering to help


Using Twitter tutorial to call standard Geo search for twitter

Posted: Tue Jan 28, 2014 2:51 pm
by Maryna Brodina

Hello! Thank you for update, glad it's working!


Using Twitter tutorial to call standard Geo search for twitter

Posted: Fri Feb 21, 2014 4:51 pm
by araskin3i

Unfortunately this issue has come up again. I dont understand why but Twitter is responding with the following response:

{"errors":[{"message":"Bad Authentication data","code":215}]}

Here is my code:
code
var params = {};

params.lat = Appery("labelLat").text();
params.long = Appery("labelLong").text();
params.accuracy = Appery("labelAccuracy").text();
params.query = Appery("searchbarTwitterPlace").val();
params.granularity = "poi&quot
var authHeader = EncodeHelper.getHeader('https://api.twitter.com/1.1/geo/search.json', params);

params.Authorization = authHeader;
serviceTwitterSearchPlace.execute({data: params});

/code

I know that the EncodeHelper.getHeader works OK because I call other Twitter APIs with it and it works fine. Though admittedly this is the one that has the most number of parameters.

Any thoughts?