Показать все твиты, которые есть на странице аккаунта Twitter пользователя - PullRequest
0 голосов
/ 14 декабря 2010

Я использовал временную шкалу пользователя для отображения всех твитов, созданных конкретным пользователем, но я пытаюсь добиться того, чтобы отобразить на своем веб-сайте все твиты, которые пользователь создал или получил.

Есть ли способ сделать это.

Ответы [ 2 ]

1 голос
/ 14 декабря 2010

Итак, вы хотите получить все твиты , сделанные пользователем и все твиты, в которых упоминается пользователь (он же отправляется пользователю)?

Дляво-первых,

http://dev.twitter.com/doc/get/statuses/public_timeline

Во-вторых, см.

http://dev.twitter.com/doc/get/statuses/mentions

Для доступа к последнему API вам потребуется использовать аутентификацию OAuth.позвонить.

0 голосов
/ 10 марта 2014

Я недавно что-то написал.Надеюсь это поможет.http://blog.rohit -lakhanpal.info / 2013/06 / console-app-that-display-twitter-feed.html

using System;
using System.Linq;
using LinqToTwitter;
using System.Threading;

namespace Linq2Twitter
{
    class Program
    {
        /// <summary>
        /// Controls the flow of the program.
        /// </summary>
        /// <param name="args">The args.</param>
        static void Main(string[] args)
        {
            // This is a super simple example that
            // retrieves the latest tweets of a given 
            // twitter user.

            // SECTION A: Initialise local variables
            Console.WriteLine("SECTION A: Initialise local variables");

            // Access token goes here .. (Please generate your own)
            const string accessToken = "Access token goes here .. (Please generate your own)";
            // Access token secret goes here .. (Please generate your own)
            const string accessTokenSecret = "Access token secret goes here .. (Please generate your own)";

            // Api key goes here .. (Please generate your own)
            const string consumerKey = "Api key goes here .. (Please generate your own)";
            // Api secret goes here .. (Please generate your own)
            const string consumerSecret = "Api secret goes here .. (Please generate your own)";

            // The twitter account name goes here
            const string twitterAccountToDisplay = "roeburg"; 


            // SECTION B: Setup Single User Authorisation
            Console.WriteLine("SECTION B: Setup Single User Authorisation");
            var authorizer = new SingleUserAuthorizer
            {
                CredentialStore = new InMemoryCredentialStore
                {
                    ConsumerKey = consumerKey,
                    ConsumerSecret = consumerSecret,
                    OAuthToken = accessToken,
                    OAuthTokenSecret = accessTokenSecret
                }
            };

            // SECTION C: Generate the Twitter Context
            Console.WriteLine("SECTION C: Generate the Twitter Context");
            var twitterContext = new TwitterContext(authorizer);

            // SECTION D: Get Tweets for user
            Console.WriteLine("SECTION D: Get Tweets for user");
            var statusTweets = from tweet in twitterContext.Status
                               where tweet.Type == StatusType.User &&
                                       tweet.ScreenName == twitterAccountToDisplay &&
                                       tweet.IncludeContributorDetails == true &&
                                       tweet.Count == 10 &&
                                       tweet.IncludeEntities == true
                               select tweet;

            // SECTION E: Print Tweets
            Console.WriteLine("SECTION E: Print Tweets");
            PrintTweets(statusTweets);
            Console.ReadLine();
        }

        /// <summary>
        /// Prints the tweets.
        /// </summary>
        /// <param name="statusTweets">The status tweets.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private static void PrintTweets(IQueryable<Status> statusTweets)
        {
            foreach (var statusTweet in statusTweets)
            {
                Console.WriteLine(string.Format("\n\nTweet From [{0}] at [{1}]: \n-{2}",
                    statusTweet.ScreenName,
                    statusTweet.CreatedAt,
                    statusTweet.Text));

                Thread.Sleep(1000);
            }
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...