我写了这个简单的代码,它运行得很好:
//access the twitter API using your twitter4j.properties file
Twitter twitter = TwitterFactory.getSingleton();
//create a new search
Query query = new Query("\"your welcome\"");
//get the results from that search
QueryResult result = twitter.search(query);
//get the first tweet from those results
Status tweetResult = result.getTweets().get(0);
//reply to that tweet
StatusUpdate statusUpdate = new StatusUpdate(".@" + tweetResult.getUser().getScreenName() +" I believe you meant \"you're\" here?");
statusUpdate.inReplyToStatusId(tweetResult.getId());
Status status = twitter.updateStatus(statusUpdate); 问题是,即使使用我自己从app.twitter.com手动生成的参数(Acessstoken,Consumerkey,,),代码仍然会将推文发送到这个帐户:Twit4j。似乎有太多的人通过它发了推文!
twitter4j.proprieties设置正确,库正确集成,有人知道哪里会出错吗?
发布于 2016-02-18 01:00:49
(我猜)问题出在类名中!包name+我的类名是"Twitter“,来自Twitter4j的对象名也是"Twitter”!你觉得IDE是不是搞混了?不管怎么说,现在它工作得很好!
https://stackoverflow.com/questions/35445386
复制相似问题