1

I am following the Spring Twitter Integration example from Pro Spring Integration book by Mark Lui and Josh Long.

But getting error saying Failed to send Status update. Detailed Error: 403:The request is understood, but it has been refused.

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

What could be the problem

Here is my 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();
}
}

and 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> 
Mahtab Alam
  • 607
  • 2
  • 9
  • 22

1 Answers1

0

403 means your credentials are incorrect.

You need to verify your OAuth consumerKey, consumerSecret, accessToken and accessTokenSecret are correctly configured.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Racil Hilan Jul 29 '15 at 17:49
  • I disagree; `What could be the problem` was the question and I answered that; but I've added some clarification. – Gary Russell Jul 29 '15 at 17:54
  • I agree that you did answer that question, but was that really all what the OP wanted to know? I bet he needed more. Your edit does give a little more sauce, so let's see what the OP will say about it. – Racil Hilan Jul 29 '15 at 18:06