/// <summary> /// Initializes the command. /// </summary> public override void Init() { // Default values this.RequestParameters.Add("cursor", "-1"); FriendsOptions options = this.OptionalProperties as FriendsOptions; if (options == null) { return; } if (options.UserId > 0) { this.RequestParameters.Add("user_id", options.UserId.ToString(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(options.ScreenName)) { this.RequestParameters.Add("screen_name", options.ScreenName); } // Override the default if (options.Cursor != 0) { this.RequestParameters["cursor"] = options.Cursor.ToString(CultureInfo.CurrentCulture); } }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="FriendsCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="options">The options.</param> public FriendsCommand(OAuthTokens tokens, FriendsOptions options) : base(HTTPVerb.GET, "statuses/friends.json", tokens, options) { this.DeserializationHandler = TwitterUserCollection.DeserializeWrapper; }