Created
January 12, 2011 17:51
-
-
Save caseycrites/776560 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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