Пример #1
0
        // ReSharper disable UnusedMember.Local
        #region Token

        #region Execute Query
        /// <summary>
        /// Simple function that uses ExecuteQuery to retrieve information from the Twitter API
        /// </summary>
        /// <param name="token"></param>

        static void ExecuteQuery(IToken token)
        {
            // Retrieving information from Twitter API through Token method ExecuteRequest
            Dictionary <string, object>[] timeline = token.ExecuteGETQueryReturningCollectionOfObjects("https://api.twitter.com/1.1/statuses/home_timeline.json");

            // Working on each different object sent as a response to the Twitter API query
            for (int i = 0; i < timeline.Length; ++i)
            {
                Dictionary <String, object> post = timeline[i];
                Console.WriteLine("{0} : {1}\n", i, post["text"]);
            }
        }
Пример #2
0
        /// <summary>
        /// Retrieve the members from the Twitter API for the list of suggested users associated to the attribute _slug.
        /// Process this data and store it in the attributes members
        /// An Exception is thrown the parameter is null, or if no data could be retrieved from Twitter.
        /// </summary>
        /// <param name="token">Token used to request data from the Twitter API</param>
        public void RefreshMembers(IToken token)
        {
            if (token == null)
            {
                throw new ArgumentException("Token must be specified in parameter");
            }

            // Request the members to the Twitter API
            Dictionary <string, object>[] twitterMembers = token.ExecuteGETQueryReturningCollectionOfObjects(String.Format(Resources.SuggestedUserList_GetMembers, this.Slug));
            if (twitterMembers != null)
            {
                // Process Twitter's response and store the members in the corresponding attribute
                ExtractMembers(twitterMembers);
                // Create a task to clear these attributes in 50 minutes from now
                AddScheduledTask();
            }
            else
            {
                HandleMembersErrorFromTwitter();
            }
        }