What's my name? (getScreenName)

26 views
Skip to first unread message

jjd

unread,
Jun 24, 2011, 10:40:42 AM6/24/11
to JTwitter
Hi.

What's my screen name? Seems like an easy question, but I'm having
trouble with it.

I authenticate with jtwitter by creating a Twitter using Twitter(null,
oauthClient). The oauthClient is properly initialized with a access
token and access token secret.

The documentation for the Twitter constructor says that username first
argument can be null.

If I subsequently call Twitter.getScreenName() (which is documented as
"Login name of the authenticating user, or null if not set.") I get a
result of null.

Is there a way to get the authenticated user's screenname if I don't
have it in the first place?

--Jim--

Daniel Winterstein

unread,
Jun 24, 2011, 1:10:03 PM6/24/11
to jt...@googlegroups.com
Hi Jim,

Not a bad question at all. If you don't know the username, but you do
have an oauth token, you can use:
User user = new TwitterAccount(jtwitter).verifyCredentials()
to fetch information on the user.
Why doesn't this happen automatically? Because it involves a call to Twitter.
Best regards,
- Daniel

--
--------------------------------------------------
Daniel Winterstein
Edinburgh
http://winterwell.com   http://soda.sh

jjd

unread,
Jun 27, 2011, 9:53:23 AM6/27/11
to JTwitter
Thanks, Daniel!
Reply all
Reply to author
Forward
0 new messages