问题描述
我要一些资源,可以使我捕捉鸣叫只能在特定的链接。
假设我会捕捉其中包含一个链接 http://aaa.com
我该怎么办呢?
谢谢
阅读有关Twitter的API ,但更好地库是。
在这里你有code样品:
-
添加新的鸣叫:
Twitter的微博= TwitterFactory.getSingleton();
状态状态= twitter.updateStatus(latestStatus);
的System.out.println(已成功更新状态[+ status.getText()+。); -
歌厅时间表:
Twitter的微博= TwitterFactory.getSingleton();
清单<状态>状态= twitter.getHomeTimeline();
的System.out.println(显示时间轴回家。);
对于(状态状态:状态){
。的System.out.println(status.getUser()的getName()+:+
status.getText());
} -
登录微博使用OAuth(code for Java中,编辑此):
Twitter的微博= TwitterFactory.getSingleton();
twitter.setOAuthConsumer([消费键],[消费秘密]);
RequestToken requestToken = twitter.getOAuthRequestToken();
的accessToken的accessToken = NULL;
BR的BufferedReader =新的BufferedReader(新的InputStreamReader(System.in));
而(空==的accessToken){
的System.out.println(打开以下网址和访问权限授予您的帐户:);
的System.out.println(requestToken.getAuthorizationURL());
System.out.print(输入PIN码(如果aviailable)或只需点击进入[密码]:);
串销= br.readLine();
尝试{
如果(pin.length()大于0){
的accessToken = twitter.getOAuthAccessToken(requestToken,脚);
}其他{
的accessToken = twitter.getOAuthAccessToken();
}
}赶上(TwitterException TE){
如果(401 == te.getStatus code()){
的System.out.println(无法获得访问令牌。);
}其他{
te.printStackTrace();
}
}
}
//坚持到的accessToken以供将来参考。
storeAccessToken(twitter.verifyCredentials()的getId(),的accessToken);
状态状态= twitter.updateStatus(参数[0]);
的System.out.println(已成功更新状态[+ status.getText()+。);
System.exit(0);}
私有静态无效storeAccessToken(INT USEID,的accessToken的accessToken){
//商店accessToken.getToken()
//商店accessToken.getTokenSecret()-
越来越鸣叫:
Twitter的微博= TwitterFactory.getSingleton();
查询查询=新的查询(来源:twitter4j yusukey);
QueryResult中结果= twitter.search(查询);
对于(状态状态:result.getStatuses()){
的System.out.println(@+ status.getUser()getScreenName()+:+ status.getText());
}
-
我希望我帮助。
来源:
I want some resource which can lead me to capture tweets for only a specific links.Suppose i will capture all tweets which contain a link http://aaa.comhow can i do it ?thanks
Read about Twitter API here, but better library is Twitter4J.
Here you have code samples to :
add new tweet :
Twitter twitter = TwitterFactory.getSingleton(); Status status = twitter.updateStatus(latestStatus); System.out.println("Successfully updated the status to [" + status.getText() + "].");
geting timeline :
Twitter twitter = TwitterFactory.getSingleton(); List<Status> statuses = twitter.getHomeTimeline(); System.out.println("Showing home timeline."); for (Status status : statuses) { System.out.println(status.getUser().getName() + ":" + status.getText()); }
Log in Twitter using OAuth (code for Java, edit this):
Twitter twitter = TwitterFactory.getSingleton(); twitter.setOAuthConsumer("[consumer key]", "[consumer secret]"); RequestToken requestToken = twitter.getOAuthRequestToken(); AccessToken accessToken = null; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (null == accessToken) { System.out.println("Open the following URL and grant access to your account:"); System.out.println(requestToken.getAuthorizationURL()); System.out.print("Enter the PIN(if aviailable) or just hit enter.[PIN]:"); String pin = br.readLine(); try{ if(pin.length() > 0){ accessToken = twitter.getOAuthAccessToken(requestToken, pin); }else{ accessToken = twitter.getOAuthAccessToken(); } } catch (TwitterException te) { if(401 == te.getStatusCode()){ System.out.println("Unable to get the access token."); }else{ te.printStackTrace(); } } } //persist to the accessToken for future reference. storeAccessToken(twitter.verifyCredentials().getId() , accessToken); Status status = twitter.updateStatus(args[0]); System.out.println("Successfully updated the status to [" + status.getText() + "]."); System.exit(0);
}
private static void storeAccessToken(int useId, AccessToken accessToken){ //store accessToken.getToken() //store accessToken.getTokenSecret()
getting tweets :
Twitter twitter = TwitterFactory.getSingleton(); Query query = new Query("source:twitter4j yusukey"); QueryResult result = twitter.search(query); for (Status status : result.getStatuses()) { System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText()); }
I hope I helped.
Source : http://twitter4j.org/en/code-examples.html
这篇关于我怎样才能得到一个特定URL的鸣叫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!