I'm also getting intermittent 502 errors, so I don't think this is
code specific. I am calling the search API and getting a 502 error
every couple of hours. The vast majority of API calls are working.
Repeating the call after a 502 error generally works.

On Oct 29, 11:41 am, hima <himaca...@gmail.com> wrote:
> Hi
> I am trying to collect users data from twitter, like the number of
> followers, number of tweets, the time the user' account is alive and
> similar statistics. I have done this before in august and got
> appropriate results with my code.I ran the code again a week ago and
> it worked and gave me results. The same code however, stopped working
> since a week now responding with a 502 bad gateway error. I am not
> able to connect to the twitter page and get the xml body. This is my
> function to return the xml page:
>
> public static String webget(String host, String doc, String username,
> String password)
>         {
>                 String body = "";
>                 byte[] auth = Base64.decode(username + ":" + password );
>                 String header = "Get " + doc + " HTTP/1.0\r\n";
>                 header += "Authorization: Basic " + auth ;
>                 header += "Accept: application/xml, text/plain, text/xml, 
> text/*\r
> \n";
>                 header += "\r\n";
>
>                 try
>                 {
>                         Socket sock = new Socket(host, 80);
>                         OutputStreamWriter os = new 
> OutputStreamWriter(sock.getOutputStream
> ());
>                         os.write(header);
>                         os.flush();
>                         sock.getOutputStream().flush();
>
>                         BufferedReader br = new BufferedReader(new
>                         InputStreamReader(sock.getInputStream()));
>                         String str = null;
>                         while ( (str = br.readLine()) != null)
>                         {
>                                 body += str + "\n";
>                         }
>                         sock.close();
>                 }
>                 catch(IOException ioe)
>                 {
>                         return "";
>                 }
>
>                 return body;
>         }
>
> This function is called like this:
>
> webget("twitter.com", "/users/show/"+UserId+".xml", USERNAME,
> PASSWORD)
>
> I have not made any changes to the code since august. I am guessing
> there have been changes in the twitter API which is giving me this
> error.However, nothing like this is mentioned in the forums. Can you
> let me know if there are changes in the twitter API that is causing
> this?
>
> Thanks
> Hima

Reply via email to