如何用scribe获取用户的推文?

时间:2012-03-28 18:48:06

标签: java twitter scribe

嗨,我仍然是Scribe的新手。我从以下情况了解到,它正在提出发布状态的请求。

private static final String PROTECTED_RESOURCE_URL = "https://api.twitter.com/1/statuses/update.json";

这是帖子网址,这就是请求的制作方式。

OAuthRequest request = new OAuthRequest(Verb.POST, PROTECTED_RESOURCE_URL);
        request.addBodyParameter("status", textArea1.getText());
        service.signRequest(accessToken, request);
        Response response = request.send();

我明白如果我想获得用户的推文,我需要用户的网址。例如,

private static final String PROTECTED_RESOURCE_URL2 = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitterusename";

如何继续提出请求并检索与此帐户相关的推文?

1 个答案:

答案 0 :(得分:1)

将带有受保护资源请求的example的行替换为:

OAuthRequest request = new OAuthRequest(Verb.GET,"http://api.twitter.com/1/statuses/user_timeline.json");
service.signRequest(accessToken, request);
Response response = request.send();
System.out.println("Got it! Lets see what we found...");
System.out.println();
System.out.println(response.getBody());