FourSquare-Woes
in
Contributed Library Questions
•
1 year ago
Hello people,
I'm trying to get foursquare-data into processing but i'm running into troubles. I've downloaded two java-api's, "foursquare4j" and the official (i believe) "foursquare V2 api for Java" but i'm a bit lost. The focus seems to lie on development for mobile devices and user-interaction while i'm creating (well, trying to ...) a desktop-application without any user-interaction or login. All i'm after is checking when/who checks in to a certain venue.
The/my problem seems to lie with the authorizing, i can't get it to work and because it's all over https i can't see what's going with wireshark for example. Plus the whole concept of a callback-url is new to me.
I feel i'm a bit in over my head, i've worked with twitter in processing before but i feel that is better documented and takes care of all the Oauth-stuff automatically (or at least i didn't see it) If anyone can offer some insight into this i would be very, very gratefull.
Thanks a bunch in advance,
FRid
This example uses the foursquare4j-api but it gives the error- "cannot find anything named response". A quick search reveals it has something to do with servlets).
This is something i've pieced together from the official api-website but it's giving me a java.lang.NullpointerException and i have no idea why. This one is using the official java-api.
I'm trying to get foursquare-data into processing but i'm running into troubles. I've downloaded two java-api's, "foursquare4j" and the official (i believe) "foursquare V2 api for Java" but i'm a bit lost. The focus seems to lie on development for mobile devices and user-interaction while i'm creating (well, trying to ...) a desktop-application without any user-interaction or login. All i'm after is checking when/who checks in to a certain venue.
The/my problem seems to lie with the authorizing, i can't get it to work and because it's all over https i can't see what's going with wireshark for example. Plus the whole concept of a callback-url is new to me.
I feel i'm a bit in over my head, i've worked with twitter in processing before but i feel that is better documented and takes care of all the Oauth-stuff automatically (or at least i didn't see it) If anyone can offer some insight into this i would be very, very gratefull.
Thanks a bunch in advance,
FRid
This example uses the foursquare4j-api but it gives the error- "cannot find anything named response". A quick search reveals it has something to do with servlets).
- import foursquare4j.exception.FoursquareException;
import foursquare4j.oauth.FoursquareOAuthImpl;
import foursquare4j.oauth.OAuthConsumer;
import foursquare4j.type.Checkin;
import foursquare4j.type.Credentials;
String id = "<ClientId>";
String secret = "<ClientSecret>";
int port = 8888;
void setup() {
size(200,200);
FoursquareApi foursquareApi = new FoursquareApi(id, secret, "Localhost:port");
try {
// First we need to redirect our user to authentication page.
response.sendRedirect(foursquareApi.getAuthenticationUrl());
} catch (IOException e) {
println(e);// TODO: Error handling
}
}
void draw() {
}
This is something i've pieced together from the official api-website but it's giving me a java.lang.NullpointerException and i have no idea why. This one is using the official java-api.
- import fi.foyt.foursquare.api.FoursquareApi;
import fi.foyt.foursquare.api.FoursquareApiException;
import fi.foyt.foursquare.api.Result;
import fi.foyt.foursquare.api.entities.CompactVenue;
import fi.foyt.foursquare.api.entities.VenuesSearchResult;
String id = "<ClientId>";
String secret = "<ClientSecret>";
String ll = args.length > 0 ? args[0] : "44.3,37.2"; - int port = 8888;
void setup() {
size(200,200);
FoursquareApi foursquareApi = new FoursquareApi(id, secret, "Localhost:port");
//FoursquareApi foursquareApi = new FoursquareApi(id, secret);
try {
Result<VenuesSearchResult> result = foursquareApi.venuesSearch(ll, null, null, null, null, null, null, null, null, null, null);
if (result.getMeta().getCode() == 200) {
// if query was ok we can finally we do something with the data
for (CompactVenue venue : result.getResult().getVenues()) {
// TODO: Do something we the data
println(venue.getName());
}
} else {
// TODO: Proper error handling
println("Error occured: ");
println(" code: " + result.getMeta().getCode());
println(" type: " + result.getMeta().getErrorType());
println(" detail: " + result.getMeta().getErrorDetail());
}
}
catch(FoursquareApiException e) {
println(e);
}
}
void draw() {
}
1