简体   繁体   中英

How to get Tweets from Twitter of perticular User in Android ?(Want to show tweets(Done by signin User) in my list view)

I am integrating Twitter with my android Application for that I am using Twitter4j 3.0.3 . till now everything is fine I have completed composing new Tweet,Upload Image,change profile picture. Now I want to show Tweets(composed by Signin User) .

For that I have used following tutorial and links

link 1

link 2

link 3

But I am not fully satisfied with these,I have tried one demo also but I am getting error of

    Invalid cookie
    header: “set-cookie: guest_id=v1%3A136932583219426033;
    Domain=.twitter.com; Path=/; Expires=Sat, 23-May-2015 16:17:12 UTC”.
    Unable to parse expires attribute: Sat, 23-May-2015 16:17:12 UTC

I tried to find out solution but I have found same solution everywhere like

Cookie Header

same issue like mine

they have shown the solution but I cant figure out where should I change in my code?

So I need one good example for Showing Tweets (which is done by User)in list view I have tried most examples as shown above, but I am getting error Invalid cookie header: so please explain me in detail how should I fix these error?

I get Answer of My Question :)

Here it is .. :)

btn_getTweets.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                tweets_list.clear();
                TwitterLogin.mTwitter.getUserTweets();
                if(tweets_list.size()==0)
                {
                    Toast.makeText(getApplicationContext(),"You haven't tweeted yet.", Toast.LENGTH_SHORT).show();
                }
                else
                {
                    tweetsAdapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,tweets_list);
                    listView.setAdapter(tweetsAdapter);
                }

            }
        });

where TwitterLogin.mTwitter class has store my Credentials. and TwitterLogin.mTwitter.getUserTweets() is method is in other class Like

public void getUserTweets(){
        System.out.println("Showing public timeline.");
        try {
            List<Status> statuses = mTwitter.getUserTimeline();
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":"
                        + status.getText());
             ComposeTwit.tweets_list.add(""+ status.getText());
            }
            Log.d("tweets_list Size", ""+ComposeTwit.tweets_list.size());
        } catch (TwitterException te) {
            System.out.println("Failed to get timeline: "
                    + te.getMessage());
            System.exit(-1);
        }

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM