araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Using Twitter tutorial to call standard Geo search for twitter

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?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Using Twitter tutorial to call standard Geo search for twitter

Hi,

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

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Using Twitter tutorial to call standard Geo search for twitter

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.

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Using Twitter tutorial to call standard Geo search for twitter

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...

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Using Twitter tutorial to call standard Geo search for twitter

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Using Twitter tutorial to call standard Geo search for twitter

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

araskin3i
Posts: 0
Joined: Fri Dec 20, 2013 2:44 pm

Using Twitter tutorial to call standard Geo search for twitter

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?

Return to “Issues”