Weird problem with XMLElement
              in 
             Core Library Questions 
              •  
              1 year ago    
            
 
           
             Hi guys,
            
            
             For some strange reason, when using the Places API from Google, and requesting more results with the pagetoken parameter, google replies to me "INVALID_REQUEST", even though the same url works in the browser, and it worked in Processing without the parameter.
            
            
             This code replicates the problem. Thanks!!:
             
             
            - int radius=1000;
 - String pos="37.77,-122.39";
 - String[] urls= {
 - "https://maps.googleapis.com/maps/api/place/textsearch/xml?query=station&types=train_station&sensor=false&key=AIzaSyCD3cU_cJWEx02Nbr6xsnmSEHNXUqH0aZA&location="+pos+"&radius="+radius
 - };
 - boolean istoken=true;
 - void setup() {
 - size(200, 200);
 - noLoop();
 - }
 - void draw() {
 - int i=0;
 - while (istoken==true && i<5) {
 - println("HI");
 - XMLElement root=new XMLElement(this, urls[urls.length-1]);
 - try {
 - XMLElement[] tokena=root.getChildren();
 - String token=tokena[tokena.length-1].getContent();
 - urls=append(urls,urls[0]+"&pagetoken="+token);
 - println (root);
 - }
 - catch(NullPointerException e) {
 - println(e);
 - istoken=false;
 - }
 - i++;
 - }
 - println (urls);
 - }
 
 
              
              1  
            
 
            