GetProfile() public method

public GetProfile ( string screenName, int count, bool includeRetweets, bool includeReplies ) : IList
screenName string
count int
includeRetweets bool
includeReplies bool
return IList
Example #1
0
        /// <summary>
        /// Get the Profile tweets from the Twitter API. Cache the results.
        /// </summary>
        /// <returns></returns>
        private IList <TwitterStatus> GetProfile()
        {
            var cacheKey = String.Format("__TwitterProfile_{0}_{1}_{2}_{3}", this.ScreenName, this.Count, this.IncludeRetweets, this.IncludeReplies);

            var results = (IList <TwitterStatus>) this.Context.Cache[cacheKey];

            if (results == null)
            {
                var api = new TwitterAPI();
                try {
                    results = api.GetProfile(this.ScreenName, this.Count, this.IncludeRetweets, this.IncludeReplies);
                } catch {
                    return(null);
                }
                this.Context.Cache.Insert(
                    cacheKey,
                    results,
                    null,
                    DateTime.UtcNow.AddSeconds(this.CacheDuration),
                    System.Web.Caching.Cache.NoSlidingExpiration
                    );
            }

            return(results);
        }
Example #2
0
        private IList <TwitterStatus> GenerateData()
        {
            if (_twitter.IsLiveContentOnDesignMode)
            {
                /*---- live mode---*/
                IList <TwitterStatus> statuses = null;
                var api = new TwitterAPI();
                switch (_twitter.Mode)
                {
                case TwitterMode.Profile:
                    statuses = api.GetProfile(_twitter.ScreenName, _twitter.Count,
                                              _twitter.IncludeRetweets, _twitter.IncludeReplies);
                    if (statuses != null && statuses.Count > 0)
                    {
                        var user = statuses[0].User;
                        _twitter.Title           = _twitter.Title ?? user.Name;
                        _twitter.Caption         = _twitter.Caption ?? user.ScreenName;
                        _twitter.ProfileImageUrl = _twitter.ProfileImageUrl ?? user.ProfileImageUrl;
                    }
                    break;

                default:
                    statuses = api.GetSearch(_twitter.Search, _twitter.Count);
                    break;
                }
                return(statuses);
            }

            /*---- fake mode --*/
            return(GenerateFakeData());
        }
Example #3
0
        /// <summary>
        /// Get the Profile tweets from the Twitter API. Cache the results.
        /// </summary>
        /// <returns></returns>
        private IList<TwitterStatus> GetProfile()
        {
            var cacheKey = String.Format("__TwitterProfile_{0}_{1}_{2}_{3}", this.ScreenName, this.Count, this.IncludeRetweets, this.IncludeReplies);

            var results = (IList<TwitterStatus>)this.Context.Cache[cacheKey];
            if (results == null) {
                var api = new TwitterAPI();
                try {
                    results = api.GetProfile(this.ScreenName, this.Count, this.IncludeRetweets, this.IncludeReplies);
                } catch {
                    return null;
                }
                this.Context.Cache.Insert(
                    cacheKey,
                    results,
                    null,
                    DateTime.UtcNow.AddSeconds(this.CacheDuration),
                    System.Web.Caching.Cache.NoSlidingExpiration
                );
            }

            return results;
        }
        private IList<TwitterStatus> GenerateData()
        {
            if (_twitter.IsLiveContentOnDesignMode) {
                /*---- live mode---*/
                IList<TwitterStatus> statuses = null;
                var api = new TwitterAPI();
                switch (_twitter.Mode) {
                    case TwitterMode.Profile:
                        statuses = api.GetProfile(_twitter.ScreenName, _twitter.Count,
                                                    _twitter.IncludeRetweets, _twitter.IncludeReplies);
                        if (statuses != null && statuses.Count > 0) {
                            var user = statuses[0].User;
                            _twitter.Title = _twitter.Title ?? user.Name;
                            _twitter.Caption = _twitter.Caption ?? user.ScreenName;
                            _twitter.ProfileImageUrl = _twitter.ProfileImageUrl ?? user.ProfileImageUrl;
                        }
                        break;
                    default:
                        statuses = api.GetSearch(_twitter.Search, _twitter.Count);
                        break;
                }
                return statuses;
            }

            /*---- fake mode --*/
            return GenerateFakeData();
        }