i am using twitter4j now. it works perfectly
On Apr 20, 2:16 am, ytbryan <[email protected]> wrote: > Hello everyone...... > > I am using commons httpclient to authenticate twitter through REST. > > however, i haven't successfully authenticate using the below code: can > someone advise me what to fill in under AuthScope? and is my > GetMethod parameter correct? > > HttpClient client = new HttpClient(); > client.getState().setCredentials( > new AuthScope("www.twitter.com", 443, "null"), > new UsernamePasswordCredentials("userid", "password") > ); > GetMethod get = new GetMethod("https://www.twitter.com"); > get.setDoAuthentication( true ); > > try { > int status = client.executeMethod( get ); > System.out.println(status + "\n" + > get.getResponseBodyAsString()); > > } catch (HttpException e1) { > e1.printStackTrace(); > } catch (IOException e1) { > e1.printStackTrace(); > } finally { > get.releaseConnection(); > } > > thanks and regards > Bryan
