0
votes

I've Downloaded and replaced the socialauth-android-2.1.jar When click the friends button, unable to get twitter friends list. It throws error.

I got below error.
04-16 10:17:05.695: I/TwitterImpl(14690): Fetching contacts from http://api.twitter.com/1/friends/ids.json?screen_name=sgm_friends&cursor=-1
04-16 10:17:05.700: D/SocialAuthAdapter(14690): Contact list not Received
04-16 10:17:05.700: W/System.err(14690): org.brickred.socialauth.exception.SocialAuthException: Failed to retrieve the contacts from http://api.twitter.com/1/friends/ids.json?screen_name=sgm_friends&cursor=-1
04-16 10:17:05.700: W/System.err(14690):    at org.brickred.socialauth.provider.TwitterImpl.getContactList(TwitterImpl.java:287)
04-16 10:17:05.705: W/System.err(14690):    at org.brickred.socialauth.android.SocialAuthAdapter.getContactList(SocialAuthAdapter.java:688)
04-16 10:17:05.705: W/System.err(14690):    at org.brickred.customui.CustomUI.Events(CustomUI.java:199)
04-16 10:17:05.705: W/System.err(14690):    at org.brickred.customui.CustomUI$ResponseListener$1.onClick(CustomUI.java:137)
04-16 10:17:05.705: W/System.err(14690):    at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:934)
04-16 10:17:05.705: W/System.err(14690):    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
04-16 10:17:05.705: W/System.err(14690):    at android.widget.AbsListView.performItemClick(AbsListView.java:1283)
04-16 10:17:05.705: W/System.err(14690):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3074)
04-16 10:17:05.705: W/System.err(14690):    at android.widget.AbsListView$1.run(AbsListView.java:4147)
04-16 10:17:05.705: W/System.err(14690):    at android.os.Handler.handleCallback(Handler.java:615)
04-16 10:17:05.705: W/System.err(14690):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-16 10:17:05.705: W/System.err(14690):    at android.os.Looper.loop(Looper.java:137)
04-16 10:17:05.705: W/System.err(14690):    at android.app.ActivityThread.main(ActivityThread.java:4898)
04-16 10:17:05.705: W/System.err(14690):    at java.lang.reflect.Method.invokeNative(Native Method)
04-16 10:17:05.710: W/System.err(14690):    at java.lang.reflect.Method.invoke(Method.java:511)
04-16 10:17:05.710: W/System.err(14690):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
04-16 10:17:05.710: W/System.err(14690):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
04-16 10:17:05.710: W/System.err(14690):    at dalvik.system.NativeStart.main(Native Method)
04-16 10:17:05.710: W/System.err(14690): Caused by: org.brickred.socialauth.exception.SocialAuthException: android.os.NetworkOnMainThreadException
04-16 10:17:05.710: W/System.err(14690):    at org.brickred.socialauth.util.HttpUtil.doHttpRequest(HttpUtil.java:154)
04-16 10:17:05.710: W/System.err(14690):    at org.brickred.socialauth.util.OAuthConsumer.send(OAuthConsumer.java:406)
04-16 10:17:05.710: W/System.err(14690):    at org.brickred.socialauth.util.OAuthConsumer.httpGet(OAuthConsumer.java:280)
04-16 10:17:05.710: W/System.err(14690):    at org.brickred.socialauth.oauthstrategy.OAuth1.executeFeed(OAuth1.java:121)
04-16 10:17:05.710: W/System.err(14690):    at org.brickred.socialauth.provider.TwitterImpl.getContactList(TwitterImpl.java:285)
04-16 10:17:05.710: W/System.err(14690):    ... 17 more
04-16 10:17:05.710: W/System.err(14690): Caused by: android.os.NetworkOnMainThreadException
04-16 10:17:05.715: W/System.err(14690):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
04-16 10:17:05.715: W/System.err(14690):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
04-16 10:17:05.715: W/System.err(14690):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
04-16 10:17:05.715: W/System.err(14690):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
04-16 10:17:05.715: W/System.err(14690):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
04-16 10:17:05.720: W/System.err(14690):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
04-16 10:17:05.720: W/System.err(14690):    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
04-16 10:17:05.720: W/System.err(14690):    at org.brickred.socialauth.util.HttpUtil.doHttpRequest(HttpUtil.java:152)
04-16 10:17:05.720: W/System.err(14690):    ... 21 more

i've posted here before 5 days. but no responce. https://code.google.com/p/socialauth-android/issues/detail?can=2&q=53&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&id=53

3
hi you are using wrong method, therefore you are getting networkos therad exception. see custom-ui example for proper usevineet

3 Answers

1
votes

Social auth people answered the question here https://code.google.com/p/socialauth-android/issues/detail?can=2&q=53&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&id=53 .

They have changed for async request. I've used older implementation,.Now the problem is resolved.

0
votes

this may Helps you See You Need ScreeName from Provide Like

HttpParameters params1 = mProvider.getResponseParameters();
String ScreeName = params1.getFirst("screen_name");

then Need to Pass this ScreenName to

https://api.twitter.com/1/friends/ids.json?cursor=-1&screen_name="+ScreeName

Here Need To call this API in AsyncTask then Which Response You get there is JsonArray of

Ids 

wich your Friends ID

0
votes

You can also get Followers and Following List using jtwitter.jar

    List<User> followers= twitter.getFollowers();
            for(int i=0;i<followers.size();i++)
            {
                User follower=followers.get(i);
                String name=follower.getName();
                Log.i("follower", name);
            }
            List<User> following = twitter.getFriends();
            for(int i=0;i<following.size();i++)
            {
                User user=following.get(i);
                String name=user.getName();
                Log.i("following", name);
            }