Guest User

Simplegeo http connect issue

a guest
Jul 25th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.util.ArrayList;
  3.  
  4. import org.apache.log4j.BasicConfigurator;
  5.  
  6. import com.simplegeo.client.SimpleGeoPlacesClient;
  7. import com.simplegeo.client.callbacks.FeatureCollectionCallback;
  8. import com.simplegeo.client.types.Feature;
  9. import com.simplegeo.client.types.FeatureCollection;
  10. import com.simplegeo.client.types.Point;
  11.  
  12. public class DelayedRequest {
  13.  
  14.     public static void main(String[] args) throws InterruptedException {
  15.         BasicConfigurator.configure();
  16.  
  17.         String secret  = ""; //secret
  18.         String key = ""; //key
  19.  
  20.         SimpleGeoPlacesClient client = SimpleGeoPlacesClient.getInstance();
  21.         client.getHttpClient().setToken(key, secret);
  22.         double radius = 25;
  23.  
  24.         for (int i=0; i< 5; i++) {
  25.  
  26.             System.out.println("Waiting..");
  27.             // wait 10 mins
  28.             Thread.sleep(10 * 1000 * 60);
  29.  
  30.             try {
  31.                
  32.                 System.out.println("Commencing Search...");
  33.                
  34.                 client.search(new Point(33.55, -122.48), "", "Restaurant", radius,
  35.                         new FeatureCollectionCallback() {
  36.                    
  37.                     public void onSuccess(FeatureCollection collection) {
  38.                         ArrayList<Feature> features = collection.getFeatures();
  39.                         for (Feature feature : features) {
  40.                             System.out.println(feature.getProperties().get("name"));
  41.                         }
  42.                     }
  43.  
  44.                     public void onError(String errorMessage) {
  45.                         System.out.println("Error: " + errorMessage);
  46.                     }
  47.                 });
  48.             } catch (IOException e) {
  49.                 System.out.println("Exception: " + e.getMessage());
  50.             }
  51.  
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment