I am working on a webpage that allows you to search for Twitter users in your area. You enter a name in the search field, and it returns users with that name 50 miles from the city (the city is always the same).
I had authentication issues and found oauth.io. I used this for authentication and it seems to work. But when I do a search, my Twitter request returns as a 400 error. I'm not sure what I'm doing wrong. I went through the oauth.io documentation but found nothing.
Here is the piece of code that gets the value of what the user entered into the form field:
$('.user-getter').submit(function(event) {
event.preventDefault();
$('.user-results').html('');
var query = $(this).find("input[name='user_search']").val();
getUser(query);
});
Here is the piece of code that calls authorization and then sends an ajax request:
var getUser = function(query) {
OAuth.initialize('oMQua1CuWerqGKRwqVkzDx5uijo')
OAuth.popup('twitter').done(function(twitterData) {
$.ajax({
type: "GET",
url: "https://api.twitter.com/1.1/users/search.json?&geocode=42.94003620000001,-78.8677924,50mi&q=" + query,
dataType: "jsonp"
});
console.log( "Data Saved: " + twitterData );
});
};
Right now, I just want to see the result in console.log.