예제 #1
0
        /// <summary>
        /// Returns the 20 most recent statuses from non-protected users who have set a custom user icon.  Does not require authentication.
        /// </summary>
        /// <returns></returns>
        public TwitterStatusCollection PublicTimeline()
        {
            TwitterRequest     Request = new TwitterRequest();
            TwitterRequestData Data    = new TwitterRequestData();

            Data.ActionUri = new Uri(Twitter.Urls.PublicTimelineUrl);

            Data = Request.PerformWebRequest(Data);

            return(Data.Statuses);
        }
예제 #2
0
        /// <summary>
        /// Destroys the status specified by the required ID parameter.  The authenticating user must be the author of the specified status.
        /// </summary>
        /// <param name="ID">Required.  The ID of the status to destroy.</param>
        public void Destroy(int ID)
        {
            TwitterRequest     Request = new TwitterRequest();
            TwitterRequestData Data    = new TwitterRequestData();

            Data.UserName = userName;
            Data.Password = password;

            Data.ActionUri = new Uri(
                string.Format(Twitter.Urls.DestroyStatusUrl, ID));

            Request.PerformWebRequest(Data);
        }
예제 #3
0
        /// <summary>
        /// Returns up to 100 of the authenticating user's friends who have most recently updated, each with current status.
        /// </summary>
        /// <param name="Parameters">Optional. Accepts ID, Page, and Since parameters.</param>
        /// <returns></returns>
        public TwitterUserCollection Friends(TwitterParameters Parameters)
        {
            // page 0 == page 1 is the start
            TwitterRequest     Request = new TwitterRequest();
            TwitterRequestData Data    = new TwitterRequestData();

            Data.UserName = userName;
            Data.Password = password;

            string actionUri = (Parameters == null ? Twitter.Urls.FriendsUrl : Parameters.BuildActionUri(Twitter.Urls.FriendsUrl));

            Data.ActionUri = new Uri(actionUri);
            Data           = Request.PerformWebRequest(Data);
            return(Data.Users);
        }
예제 #4
0
        /// <summary>
        /// Returns a single status, specified by the id parameter
        /// </summary>
        /// <param name="ID">id.  Required.  The numerical ID of the status you're trying to retrieve.</param>
        /// <returns></returns>
        public TwitterUser Show(string ID)
        {
            TwitterRequest     Request = new TwitterRequest();
            TwitterRequestData Data    = new TwitterRequestData();

            Data.UserName = userName;
            Data.Password = password;

            Data.ActionUri = new Uri(
                string.Format(Twitter.Urls.ShowStatusUrl, ID));

            Data = Request.PerformWebRequest(Data, "GET");

            return(Data.Users[0]);
        }
예제 #5
0
        /// <summary>
        /// Returns a list of the most recent direct messages sent by the authenticating user.
        /// </summary>
        /// <param name="Parameters">Accepts Since, SinceID, and Page parameters</param>
        /// <returns></returns>
        public TwitterStatusCollection DirectMessagesSent(TwitterParameters Parameters)
        {
            TwitterRequest     Request = new TwitterRequest();
            TwitterRequestData Data    = new TwitterRequestData();

            Data.UserName = userName;
            Data.Password = password;

            string actionUri = (Parameters == null ? Twitter.Urls.SentDirectMessagesUrl : Parameters.BuildActionUri(Twitter.Urls.SentDirectMessagesUrl));

            Data.ActionUri = new Uri(actionUri);

            Data = Request.PerformWebRequest(Data);

            return(Data.Statuses);
        }
예제 #6
0
        /// <summary>
        /// Updates the authenticating user's status.
        /// </summary>
        /// <param name="Status">Required.  The text of your status update.</param>
        /// <param name="InReplyToStatusID">Optional.  The ID of an existing status that the status to be posted is in reply to.</param>
        /// <returns></returns>
        public TwitterStatus Update(string Status, long?InReplyToStatusID)
        {
            TwitterRequest     Request = new TwitterRequest();
            TwitterRequestData Data    = new TwitterRequestData();

            Data.UserName = userName;
            Data.Password = password;
            Data.Source   = source;

            Data.ActionUri = new Uri(
                string.Format(Twitter.Urls.UpdateUrl, HttpUtility.UrlEncode(Status), source,
                              InReplyToStatusID.HasValue ? InReplyToStatusID.Value.ToString() : ""));

            Data = Request.PerformWebRequest(Data, "POST");

            return(Data.Statuses[0]);
        }
예제 #7
0
        public static bool VerifyCredentials(string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                Console.Error.WriteLine("username empty");
            }

            if (string.IsNullOrEmpty(password))
            {
                Console.Error.WriteLine("password empty");
            }

            TwitterRequest     request = new TwitterRequest();
            TwitterRequestData data    = new TwitterRequestData();

            data.UserName  = username;
            data.Password  = password;
            data.ActionUri = new Uri(Urls.VerifyCredentialsUrl);

            try
            {
                data = request.PerformWebRequest(data, "GET");
                if (data == null)
                {
                    Console.Error.WriteLine("DATA IS NULL ABORT");
                    return(false);
                }

                if (data.Users[0].ScreenName == username)
                {
                    return(true);
                }
            }
            catch { }             // ignore exeptions - authentication failed

            return(false);
        }