Skip to content

Instantly share code, notes, and snippets.

@caseycrites
Created January 12, 2011 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save caseycrites/776560 to your computer and use it in GitHub Desktop.
Save caseycrites/776560 to your computer and use it in GitHub Desktop.
package com.simplejavaapp;
import java.io.IOException;
import java.util.ArrayList;
import com.simplegeo.client.SimpleGeoPlacesClient;
import com.simplegeo.client.types.Feature;
import com.simplegeo.client.types.FeatureCollection;
public class SimpleJavaClass {
public static void main(String[] args) {
SimpleGeoPlacesClient client = new SimpleGeoPlacesClient();
client.getHttpClient().setToken("oauth-key", "oauth-secret");
try {
HashMap<String, String[]> queryParams = new HashMap<String, String[]>();
queryParams.put("radius", new String[] {"25"});
client.searchByIP(queryParams, new SimpleGeoCallback() {
public void onSuccess(String jsonResponse) {
FeatureCollection collection = FeatureCollection.fromJSONString(jsonResponse);
ArrayList<Feature> features = collection.getFeatures();
for (Feature feature : features) {
System.out.println(feature.getProperties().get("name"));
}
}
public void onError(String errorMessage) {
System.out.println(errorMessage);
}
});
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment