1

我正在关注 Mark Lui 和 Josh Long 的 Pro Spring Integration 书中的 Spring Twitter Integration 示例。

但收到错误提示无法发送状态更新。详细错误:403:请求被理解,但已被拒绝。

Exception in thread "main" org.springframework.integration.MessageHandlingException: error occurred in message handler [org.springframework.integration.twitter.outbound.StatusUpdatingMessageHandler#0]
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:84)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
at edureka.TwitterOutbound.main(TwitterOutbound.java:18)

Caused by: org.springframework.integration.twitter.core.TwitterOperationException: Failed to send Status update.  Detailed Error: 403:The request is understood, but it has been refused.  An accompanying error message will explain why.
For more information about this exception please visit the following Twitter website: http://apiwiki.twitter.com/w/page/22554652/HTTP-Response-Codes-and-Errors
at org.springframework.integration.twitter.core.Twitter4jTemplate.updateStatus(Twitter4jTemplate.java:179)
at org.springframework.integration.twitter.outbound.StatusUpdatingMessageHandler.handleMessageInternal(StatusUpdatingMessageHandler.java:57)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
... 6 more

可能是什么问题呢

这是我的 TwitterOutbound.java

public class TwitterOutbound {
public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "/twitter-outbound.xml", TwitterOutbound.class);
    MessageChannel input = context.getBean("twitterOutbound",
            MessageChannel.class);
    Message<String> message = MessageBuilder.withPayload(
            "Only can get and send message once "
                    + Calendar.getInstance().getTimeInMillis()).build();
    input.send(message);
    context.stop();
}
}

和 twitter-outbound.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:twitter="http://www.springframework.org/schema/integration/twitter"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/integration/twitter
http://www.springframework.org/schema/integration/twitter/spring-integration-twitter-2.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">


<context:component-scan base-package="edureka"/>
<context:property-placeholder location="/twitter.properties"/>
<int:channel id="twitterOutbound"/> 

<twitter:outbound-channel-adapter twitter-template="twitterTemplate"
channel="twitterOutbound"/>
</beans> 
4

1 回答 1

0

403表示您的凭据不正确。

您需要验证您的 OAuth 、 和consumerKey配置consumerSecret是否正确。accessTokenaccessTokenSecret

于 2015-07-29T13:21:26.127 回答