public static TwitterResponse <TwitterUserCollection> Friends(OAuthTokens tokens, FriendsOptions options)
        {
            Commands.FriendsCommand command = new Commands.FriendsCommand(tokens, options);

            return(CommandPerformer.PerformAction(command));
        }
 public static TwitterResponse <TwitterUserCollection> Friends(FriendsOptions options)
 {
     return(Friends(null, options));
 }
        public static TwitterResponse<TwitterUserCollection> Friends(OAuthTokens tokens, FriendsOptions options)
        {
            Commands.FriendsCommand command = new Commands.FriendsCommand(tokens, options);

            return CommandPerformer.PerformAction(command);
        }
 public static TwitterResponse<TwitterUserCollection> Friends(FriendsOptions options)
 {
     return Friends(null, options);
 }
Beispiel #5
0
        private void UpdateFriends()
        {
            Trace.Call();

            if (f_Friends != null) {
                return;
            }

            #if LOG4NET
            f_Logger.Debug("UpdateFriends(): getting friends from twitter...");
            #endif
            var options = new FriendsOptions() {
                Proxy = f_WebProxy
            };
            TwitterUserCollection friends = TwitterFriendship.Friends(
                f_OAuthTokens, options
            );
            #if LOG4NET
            f_Logger.Debug("UpdateFriends(): done. Friends: " +
                (friends == null ? 0 : friends.Count));
            #endif
            if (friends == null || friends.Count == 0) {
                return;
            }

            var persons = new Dictionary<string, PersonModel>(friends.Count);
            foreach (TwitterUser friend in friends) {
                var person = CreatePerson(friend);
                persons.Add(person.ID, person);
            }
            f_Friends = persons;
        }
        /// <summary>
        /// Get the Twitter response object for the friends
        /// </summary>
        /// <returns></returns>
        private TwitterResponse<TwitterUserCollection> GetTwitterFriends()
        {
            TwitterResponse<TwitterUserCollection> twitterResponse = new TwitterResponse<TwitterUserCollection>();

            if (Page.Cache[string.Format("TwitterFriends-{0}", this.ScreenName)] == null)
            {
                //create a authorization token of the user
                OAuthTokens tokens = new OAuthTokens();
                tokens.ConsumerKey = this.ConsumerKey;
                tokens.ConsumerSecret = this.ConsumerSecret;
                tokens.AccessToken = this.AccessToken;
                tokens.AccessTokenSecret = this.AccessTokenSecret;

                //Set the query options
                FriendsOptions Friendoptions = new FriendsOptions();
                Friendoptions.ScreenName = this.ScreenName;
                Friendoptions.Cursor = -1;

                //get the Following Object from the Twitter
                twitterResponse = TwitterFriendship.Friends(tokens, Friendoptions);
                HttpContext.Current.Cache.Insert(string.Format("TwitterFriends-{0}", this.ScreenName), twitterResponse, null, DateTime.Now.AddMinutes(Common.CACHEDURATION), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
            }
            else
            {
                twitterResponse = Page.Cache[string.Format("TwitterFriends-{0}", this.ScreenName)] as TwitterResponse<TwitterUserCollection>;
            }

            return twitterResponse;
        }