Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mark 122 posts 255 karma points
    Jun 24, 2015 @ 09:22
    Mark
    0

    Show favourite tweets for user

    I'm trying to show just favourite tweets for a given user, but I've not managed to find how to do it.

    Using TwitterServive GetUserTimeline is always returning empty, I'm guessing because the account never actually tweets. I just want a list of tweets that have been favourited by this account.

    Any help would be appreciated, I'm sure it must be simple really, I just can't see how at the moment.

    Thanks in advance..

    Mark

  • MuirisOG 382 posts 1284 karma points
    Jun 24, 2015 @ 09:35
    MuirisOG
    0

    Mark see the link below for how to do Twitter feeds, then build your own user control to display them on a page. https://dev.twitter.com/web/embedded-timelines

    However, I would say your query lies in the "let me google that for you" category :-D

  • Mark 122 posts 255 karma points
    Jun 24, 2015 @ 09:41
    Mark
    0

    Well I did some Googling, but as I couldn't see an obvious way of doing it using the Skybrud methods. That said, I just had an epiphany and discovered that it's easy to get the list of favourites for the currently aunthenticated user, even if I can't easily see if for other screen names.

    Just means I need to re-autheticate as the account that I want the favourites for, which it will be when the site goes live anyway.

    Job done.

    Thanks

    Mark

  • MuirisOG 382 posts 1284 karma points
    Jun 24, 2015 @ 11:53
    MuirisOG
    0

    Mark, it looks like there's been a glitch in our.umbraco, and I'm sorry but I didn't see that you were on a particular topic area for Skybrud.Social. Apologies for the mix-up - I thought that this was a general question you had put out there.

  • MuirisOG 382 posts 1284 karma points
    Jun 24, 2015 @ 10:46
    MuirisOG
    0

    Mark that looks like something we could use. Any chance you could post a bit more detail when you've finished? We tend to create a list on a Twitter account, which we then pull into a feed. But this gets everything for the accounts on the list (use Tweetdeck to add the Twitter account with the list to the list).

    Plus, it saves me Googling...

  • Anders Bjerner 487 posts 2995 karma points MVP 8x admin c-trib
    Jun 24, 2015 @ 11:04
    Anders Bjerner
    1

    Hi Mark,

    This is not something that has been implemented in Skybrud.Social yet. But by utilizing some of the existing classes, you can get the favorites like:

    // Declare the query string (eg. for specifying the count/limit)
    NameValueCollection query = new NameValueCollection();
    query.Add("count", "200");
    
    // Make a raw request using the OAuth client since getting the favorites isn't actually supported yet in Skybrud.Social
    SocialHttpResponse rawResponse = service.Client.DoHttpGetRequest("https://api.twitter.com/1.1/favorites/list.json", query);
    
    // Parse the raw response into an strongly typed response
    TwitterTimelineResponse response = TwitterTimelineResponse.ParseResponse(rawResponse);
    
    foreach (var tweet in response.Body) {
    
        <p>@tweet.Text</p>
    
    }
    

    This will give you the 200 most recent favorites of the authenticated user.

    If you want to get the favorites of specific users - eg. by their screen name, you can use the example below instead:

    // Declare the query string (eg. for specifying the count/limit)
    NameValueCollection query = new NameValueCollection();
    query.Add("count", "200");
    query.Add("screen_name", "enter the screen name here");
    
    // Make a raw request using the OAuth client since getting the favorites isn't actually supported yet in Skybrud.Social
    SocialHttpResponse rawResponse = service.Client.DoHttpGetRequest("https://api.twitter.com/1.1/favorites/list.json", query);
    
    // Parse the raw response into an strongly typed response
    TwitterTimelineResponse response = TwitterTimelineResponse.ParseResponse(rawResponse);
    
    foreach (var tweet in response.Body) {
    
        <p>@tweet.Text</p>
    
    }
    
  • Mark 122 posts 255 karma points
    Jun 24, 2015 @ 12:22
    Mark
    0

    Hi MuirisOG / Anders,

    I'm simply doing the following now, which appears to be working, though like I said above, only fr the authenticated user:

    TwitterOAuthData twitter = settingsNode.GetPropertyValue("twitterAuthentication") as TwitterOAuthData;
    
    TwitterService service = twitter.GetService();
    
    var tweetsAlt = service.Statuses.GetHomeTimeline().Body;
    foreach (var tweet in tweetsAlt.Where(x => x.HasFavorited))//.Where(x => x.HasFavorited).OrderByDescending(x => x.CreatedAt))
    {
        <p>@(tweet.Text)</p>
    }
    
  • Mark 122 posts 255 karma points
    Jun 24, 2015 @ 12:24
    Mark
    0

    And our.umbraco does seem to be playing up a it, you're right..

    It looked to me like I was in the wrong forum earlier, then when I came back it looked ok. I currently can't see anyone's karma or anything either..

    Oh well, luckily I'm not easily offended or wound up ;-)

Please Sign in or register to post replies

Write your reply to:

Draft