I created an APP in twitter; gave it Read/write access, regen keys (accessToken,accessTokenSecret,consumerSecret.consumerKey}; put the values into twitter4j.properties file; coded a demo Status Listener: get "User not in role"


#1

I created an APP in twitter; I gave it Read/write access, and then regenerated keys (accessToken,accessTokenSecret,consumerSecret.consumerKey}.
I put the values into twitter4j.properties file; and then wrote a demo Status Listener. and when I run it I get: “User not in role”

Code:

TwitterStream twitterStream=new TwitterStreamFactory().getInstance();
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
System.out.println("@" + status.getUser().getScreenName() +
" - " + status.getText());
}

        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            System.out.println("Got a status deletion notice id:" +
                               statusDeletionNotice.getStatusId());
        }

        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            System.out.println("Got track limitation notice:" +
                               numberOfLimitedStatuses);
        }

        public void onScrubGeo(long userId, long upToStatusId) {
            System.out.println("Got scrub_geo event userId:" + userId +
                               " upToStatusId:" + upToStatusId);
        }

        public void onException(Exception ex) {
            ex.printStackTrace();
        }
    };
    twitterStream.addListener(listener);
    twitterStream.firehose(0);

ERROR:
[Fri Jul 29 11:30:08 PDT 2011]Will use class twitter4j.internal.logging.StdOutLoggerFactory as logging factory.
[Fri Jul 29 11:30:08 PDT 2011]Will use twitter4j.internal.http.HttpClientImpl as HttpClient implementation.
[Fri Jul 29 11:30:08 PDT 2011]Establishing connection.
[Fri Jul 29 11:30:08 PDT 2011]Twitter Stream consumer-1[Establishing connection]
[Fri Jul 29 11:30:08 PDT 2011]Request:
[Fri Jul 29 11:30:08 PDT 2011]POST http://stream.twitter.com/1/statuses/firehose.json
[Fri Jul 29 11:30:08 PDT 2011]OAuth base string: POST&http%3A%2F%2Fstream.twitter.com%2F1%2Fstatuses%2Ffirehose.json&count%3D0%26oauth_consumer_key%3D6ybyJFQFSdNjfg3bn5dMQ%26oauth_nonce%3D2866835517%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1311964208%26oauth_token%3D344120042-FJLlAVvdUG04Gn3GPwuugWoaB34rrLQULYSAkqYX%26oauth_version%3D1.0
[Fri Jul 29 11:30:08 PDT 2011]OAuth signature: OKLbKopSAGQBmtwI05bBFk3F5Ko=
[Fri Jul 29 11:30:08 PDT 2011]Authorization: *******************************************************************************************************************************************************************************************************************************************************************************
[Fri Jul 29 11:30:08 PDT 2011]X-Twitter-Client-URL: http://twitter4j.org/en/twitter4j-2.2.3.xml
[Fri Jul 29 11:30:08 PDT 2011]X-Twitter-Client: Twitter4J
[Fri Jul 29 11:30:08 PDT 2011]Accept-Encoding: gzip
[Fri Jul 29 11:30:08 PDT 2011]User-Agent: twitter4j http://twitter4j.org/ /2.2.3
[Fri Jul 29 11:30:08 PDT 2011]X-Twitter-Client-Version: 2.2.3
[Fri Jul 29 11:30:08 PDT 2011]Post Params: count=0
[Fri Jul 29 11:30:08 PDT 2011]Response:
[Fri Jul 29 11:30:08 PDT 2011]HTTP/1.1 403 Forbidden
[Fri Jul 29 11:30:08 PDT 2011]Transfer-Encoding: chunked
[Fri Jul 29 11:30:08 PDT 2011]Content-Type: text/html; charset=iso-8859-1
[Fri Jul 29 11:30:08 PDT 2011]Server: Jetty(6.1.25)
[Fri Jul 29 11:30:08 PDT 2011]User not in role

[Fri Jul 29 11:30:08 PDT 2011]403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (http://support.twitter.com/forums/10711/entries/15364).
User not in role

[Fri Jul 29 11:30:08 PDT 2011]This account is not in required role. 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (http://support.twitter.com/forums/10711/entries/15364).
User not in role

Process exited.
Debugger disconnected from local process.


#2

The /statuses/firehose.json endpoint isn’t available for widespread use. You likely want to connect to /statuses/sample.json instead.


#3

In our production I’d like to use firehose, so how can I setup my application to pickup all the tweets on twitter?

Yet, for testing I’d like to use sample, so how can I post a new tweet to the sample stream to test this out?
Thanks,
Joel


#4

The firehose is not a resource made available to most developers. In almost all circumstances, you will have to work with a smaller data set than “all tweets on Twitter.” Depending on how you want to utilize tweets, you may find the elevated options offered by Gnip and Datasift useful – see [node:230].


#5

How about the 2nd question - how do I post a tweet to the twitter sample stream to see it show up in my Stream?

Thanks for the help!
Joel


#6

The sample stream is a random sample of 1% of the tweets being issues publicly. There’s no way you can tweet and guarantee that it’ll be part of that 1% sample being issued on the sample stream.

However, if you explore the usage of the statuses/filter.json method of the streaming API, you could use the follow parameter to follow your own user id, then tweet something either through the API or through the website or an application, and see the streamed event. See https://dev.twitter.com/docs/streaming-api/methods#follow for more information on the follow parameter of filter.json


#7

Thanks - I appreciate your help!


#8

Hi all,

how can filter only geo located messages ?