示例#1
0
        public static TwitterTimeline ParseJson(string contents)
        {
            // Deserialize the JSON
            IJsonObject json = JsonConverter.Parse(contents);

            // Can there be multiple errors? Need. More. Data.
            JsonObject obj = json as JsonObject;

            if (obj != null)
            {
                JsonArray errors = obj.GetArray("errors");
                throw new TwitterException(
                          errors.GetObject(0).GetInt("code"),
                          errors.GetObject(0).GetString("message")
                          );
            }

            // Cast to an array
            JsonArray array = (JsonArray)json;

            // Return the instance
            return(new TwitterTimeline {
                JsonArray = array,
                StatusMessages = TwitterStatusMessage.ParseMultiple(array)
            });
        }
示例#2
0
 /// <summary>
 /// Destroys the status with the specified <code>id</code>. The authenticating user must be the author of the
 /// specified status. Returns the destroyed status if successful.
 /// </summary>
 /// <param name="status">The status to be destroyed.</param>
 /// <param name="trimUser">When set to <code>true</code>, each tweet returned in a timeline will include a user
 /// object including only the status authors numerical ID. Omit this parameter to receive the complete user
 /// object.</param>
 /// <returns>Returns the response from the API.</returns>
 public TwitterStatusMessageResponse DestroyStatusMessage(TwitterStatusMessage status, bool trimUser)
 {
     if (status == null)
     {
         throw new ArgumentNullException("status");
     }
     return(DestroyStatusMessage(status.Id, trimUser));
 }
示例#3
0
 /// <summary>
 /// Retweets the specified <code>status</code>.
 /// </summary>
 /// <param name="status">The tweet to be retweeted.</param>
 /// <returns>Returns the response from the API.</returns>
 public TwitterStatusMessageResponse Retweet(TwitterStatusMessage status)
 {
     if (status == null)
     {
         throw new ArgumentNullException("status");
     }
     return(Retweet(status.Id, false));
 }
示例#4
0
 /// <summary>
 /// Destroys the specified <paramref name="status"/>. The authenticating user must be the author of the
 /// specified status. Returns the destroyed status if successful.
 /// </summary>
 /// <param name="status">The status to be destroyed.</param>
 /// <returns>Returns the response from the API.</returns>
 public TwitterGetStatusMessageResponse DestroyStatusMessage(TwitterStatusMessage status)
 {
     if (status == null)
     {
         throw new ArgumentNullException(nameof(status));
     }
     return(DestroyStatusMessage(status.Id, false));
 }
示例#5
0
 /// <summary>
 /// Retweets the specified <paramref name="status"/>.
 /// </summary>
 /// <param name="status">The status to be retweeted.</param>
 /// <param name="trimUser">When set to <code>true</code>, each tweet returned in a timeline will include a user
 /// object including only the status authors numerical ID. Omit this parameter to receive the complete user
 /// object.</param>
 /// <returns>Returns the response from the API.</returns>
 public TwitterGetStatusMessageResponse Retweet(TwitterStatusMessage status, bool trimUser)
 {
     if (status == null)
     {
         throw new ArgumentNullException(nameof(status));
     }
     return(Retweet(status.Id, trimUser));
 }
 /// <summary>
 /// Destroys the specified <paramref name="statusMessage"/>. The authenticating user must be the author of the
 /// specified status message. Returns the destroyed status message if successful.
 /// </summary>
 /// <param name="statusMessage">The status meessage to be destroyed.</param>
 /// <param name="trimUser">When set to <c>true</c>, each tweet returned in a timeline will include a user
 /// object including only the status authors numerical ID. Omit this parameter to receive the complete user
 /// object.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public SocialHttpResponse DestroyStatusMessage(TwitterStatusMessage statusMessage, bool trimUser)
 {
     if (statusMessage == null)
     {
         throw new ArgumentNullException(nameof(statusMessage));
     }
     return(DestroyStatusMessage(statusMessage.Id, trimUser));
 }
 /// <summary>
 /// Retweets the specified <paramref name="statusMessage"/>.
 /// </summary>
 /// <param name="statusMessage">The status message to be retweeted.</param>
 /// <returns>An instance of <see cref="SocialHttpResponse"/> representing the raw response.</returns>
 public SocialHttpResponse RetweetStatusMessage(TwitterStatusMessage statusMessage)
 {
     if (statusMessage == null)
     {
         throw new ArgumentNullException(nameof(statusMessage));
     }
     return(RetweetStatusMessage(statusMessage.Id, false));
 }
示例#8
0
 /// <summary>
 /// Destroys the specified <paramref name="statusMessage"/>. The authenticating user must be the author of the
 /// specified status message. Returns the destroyed status message if successful.
 /// </summary>
 /// <param name="statusMessage">The status meessage to be destroyed.</param>
 /// <returns>An instance of <see cref="IHttpResponse"/> representing the raw response.</returns>
 public IHttpResponse DestroyStatusMessage(TwitterStatusMessage statusMessage)
 {
     if (statusMessage == null)
     {
         throw new ArgumentNullException(nameof(statusMessage));
     }
     return(DestroyStatusMessage(statusMessage.Id, false));
 }
示例#9
0
 /// <summary>
 /// Retweets the specified <paramref name="statusMessage"/>.
 /// </summary>
 /// <param name="statusMessage">The status message to be retweeted.</param>
 /// <param name="trimUser">When set to <code>true</code>, each tweet returned in a timeline will include a user
 /// object including only the status authors numerical ID. Omit this parameter to receive the complete user
 /// object.</param>
 /// <returns>An instance of <see cref="IHttpResponse"/> representing the raw response.</returns>
 public IHttpResponse RetweetStatusMessage(TwitterStatusMessage statusMessage, bool trimUser)
 {
     if (statusMessage == null)
     {
         throw new ArgumentNullException(nameof(statusMessage));
     }
     return(RetweetStatusMessage(statusMessage.Id, trimUser));
 }
示例#10
0
        public static SocialImage ReturnSocialImage(TwitterStatusMessage item)
        {
            SocialImage s          = new SocialImage();
            var         imageMedia = item.Entities.Media != null?item.Entities.Media.FirstOrDefault() : null;

            var urlMedia = item.Entities.Urls != null?item.Entities.Urls.FirstOrDefault() : null;

            var image       = imageMedia != null ? imageMedia.MediaUrl: "";
            var url         = imageMedia != null ? imageMedia.Url : "";
            var urlToRemove = url.Split(' ').Last();

            s.Image      = image;
            s.Date       = item.CreatedAt;
            s.Caption    = !string.IsNullOrWhiteSpace(item.Text) && !string.IsNullOrWhiteSpace(urlToRemove) ? item.Text.Replace(urlToRemove, string.Empty) : "";
            s.SocialLink = url;
            return(s);
        }
示例#11
0
 /// <summary>
 /// Destroys the specified <paramref name="statusMessage"/>. The authenticating user must be the author of the
 /// specified status message. Returns the destroyed status message if successful.
 /// </summary>
 /// <param name="statusMessage">The status meessage to be destroyed.</param>
 /// <param name="trimUser">When set to <code>true</code>, each tweet returned in a timeline will include a user
 /// object including only the status authors numerical ID. Omit this parameter to receive the complete user
 /// object.</param>
 /// <returns>An instance of <see cref="TwitterDestroyStatusMessageResponse"/> representing the response.</returns>
 public TwitterDestroyStatusMessageResponse DestroyStatusMessage(TwitterStatusMessage statusMessage, bool trimUser)
 {
     return(TwitterDestroyStatusMessageResponse.ParseResponse(Raw.DestroyStatusMessage(statusMessage, trimUser)));
 }
示例#12
0
 /// <summary>
 /// Destroys the specified <paramref name="statusMessage"/>. The authenticating user must be the author of the
 /// specified status message. Returns the destroyed status message if successful.
 /// </summary>
 /// <param name="statusMessage">The status meessage to be destroyed.</param>
 /// <returns>An instance of <see cref="TwitterDestroyStatusMessageResponse"/> representing the response.</returns>
 public TwitterDestroyStatusMessageResponse DestroyStatusMessage(TwitterStatusMessage statusMessage)
 {
     return(TwitterDestroyStatusMessageResponse.ParseResponse(Raw.DestroyStatusMessage(statusMessage)));
 }
示例#13
0
 /// <summary>
 /// Retweets the specified <paramref name="statusMessage"/>.
 /// </summary>
 /// <param name="statusMessage">The status message to be retweeted.</param>
 /// <param name="trimUser">When set to <c>true</c>, each tweet returned in a timeline will include a user
 /// object including only the status authors numerical ID. Omit this parameter to receive the complete user
 /// object.</param>
 /// <returns>An instance of <see cref="TwitterRetweetStatusMessageResponse"/> representing the response.</returns>
 public TwitterRetweetStatusMessageResponse RetweetStatusMessage(TwitterStatusMessage statusMessage, bool trimUser)
 {
     return(TwitterRetweetStatusMessageResponse.ParseResponse(Raw.RetweetStatusMessage(statusMessage, trimUser)));
 }
示例#14
0
 /// <summary>
 /// Retweets the specified <paramref name="statusMessage"/>.
 /// </summary>
 /// <param name="statusMessage">The status message to be retweeted.</param>
 /// <returns>An instance of <see cref="TwitterRetweetStatusMessageResponse"/> representing the response.</returns>
 public TwitterRetweetStatusMessageResponse RetweetStatusMessage(TwitterStatusMessage statusMessage)
 {
     return(TwitterRetweetStatusMessageResponse.ParseResponse(Raw.RetweetStatusMessage(statusMessage)));
 }
 /// <summary>
 /// Posts the specified status message.
 /// </summary>
 /// <param name="status">The status message to send.</param>
 /// <param name="replyTo">The ID of the status message to reply to.</param>
 public TwitterStatusMessage PostStatusMessage(string status, long?replyTo)
 {
     return(TwitterStatusMessage.ParseJson(Raw.PostStatusMessage(status, replyTo)));
 }
 /// <summary>
 /// Gets information about a status message (tweet) with the specified ID.
 /// </summary>
 /// <param name="statusId">The ID of the status message.</param>
 /// <param name="options">Options affecting the response from the Twitter API.</param>
 public TwitterStatusMessage GetStatusMessage(long statusId, TwitterStatusMessageOptions options = null)
 {
     return(TwitterStatusMessage.ParseJson(Raw.GetStatusMessage(statusId, options)));
 }