How to get user data through twitter's Fabric API (Android) -
i've integrated twitter's fabric api in project twitter login button
<com.twitter.sdk.android.core.identity.twitterloginbutton android:id="@+id/twitter_login_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true"/>
a manifest permission
<meta-data android:name="io.fabric.apikey" android:value="myfabrickey" />
initialization
//field declerations private static final string twitter_key = "yourtwkey"; private static final string twitter_secret = "yoursecret"; //inside oncreate twitterauthconfig authconfig = new twitterauthconfig(twitter_key, twitter_secret); fabric.with(this, new crashlytics(), new twitter(authconfig)); loginbuttontwitter = (twitterloginbutton) findviewbyid(r.id.twitter_login_button); loginbuttontwitter.setcallback(new callback<twittersession>() { @override public void success(result<twittersession> result) { // result, provides twittersession making api calls } @override public void failure(twitterexception exception) { // on failure } }); //inside onactivityresult loginbuttontwitter.onactivityresult(requestcode, resultcode, data);
my question is, how user data in json format once authenticate account.
ok! quite simple. (was trying during midnight guess half of brain asleep :p) referenced link https://twittercommunity.com/t/android-get-user-profile-image/30579/6 in user object, you'll stuff.
twittersession session = twitter.getsessionmanager().getactivesession(); twitter.getapiclient(session).getaccountservice() .verifycredentials(true, false, new callback<user>() { @override public void success(result<user> userresult) { user user = userresult.data; twitterimage = user.profileimageurl; } @override public void failure(twitterexception e) { } });
Comments
Post a Comment