我已经成功地启动并运行了一些"Spring-scheduled“任务。我现在想要的是发布一些特定的推文到一个已知的Twitter帐户(并且已经在Twitter端配置),基于一些事件重复。
然而,我在OAuth进程中看到的所有东西,尤其是。为了获得访问令牌,它需要一些回调URL才能执行任何操作。我可能错了,但这似乎很难集成到计划任务的上下文中。
有没有其他的方式来实现tweeting?
发布于 2013-02-14 02:33:10
结合Spring Scheduling特性,我将使用Twitter4j在计划的作业中发布推文。
下面是一个示例:
@Componet
public class TwitterSender {
@Scheduled(fixedRate = 10000)
public void sendTweet() {
Twitter twitter = TwitterFactory.getSingleton();
Status status = twitter.updateStatus(latestStatus);
System.out.println("Status updated to: " + status.getText() + ".");
}
}如果您需要更多信息,可以查看the test case for sending update status with Twitter4j。或者你可以直接使用dive and see the source。
发布于 2013-02-14 02:37:18
就学习曲线而言,这可能是一个小小的飞跃,但你看过spring-integration的twitter:outbound-channel-adapter吗?
<twitter:outbound-channel-adapter twitter-template="twitterTemplate"
channel="twitterChannel"/>http://static.springsource.org/spring-integration/docs/latest-ga/reference/html/twitter.html
https://stackoverflow.com/questions/14860404
复制相似问题