Exemple #1
0
        /// <summary>
        /// 获取指定ID的微博
        /// </summary>
        /// <param name="lStatusID">要获取微博内容的微博ID</param>
        /// <returns>微博</returns>
        public Status GetStatus(long lStatusID)
        {
            System.Threading.Thread.Sleep(iSleep);
            JsonStatus oJsonStatus = api.API.Statuses_Show(lStatusID);

            if (oJsonStatus == null)
            {
                Status s = new Status();
                s.status_id = -1;
                return(s);
            }
            return(JsonStatusToStatus(oJsonStatus));
        }
Exemple #2
0
        //transform a JsonStatus object to a Status object
        private Status JsonStatusToStatus(JsonStatus oJsonStatus)
        {
            Status status = new Status();

            status.created_at = PubHelper.ParseDateTime(oJsonStatus.created_at);
            status.status_id  = oJsonStatus.id;
            status.content    = oJsonStatus.text;
            if (oJsonStatus.source != null)
            {
                status.source_url  = oJsonStatus.source.Substring(9, oJsonStatus.source.IndexOf("rel") - 11);
                status.source_name = oJsonStatus.source.Substring(oJsonStatus.source.IndexOf('>') + 1, oJsonStatus.source.IndexOf("</") - oJsonStatus.source.IndexOf('>') - 1);
            }
            status.favorited = oJsonStatus.favorited;
            status.truncated = oJsonStatus.truncated;
            if (oJsonStatus.geo != null)
            {
                status.geo_type          = oJsonStatus.geo.type.ToLower();
                status.geo_coordinates_x = oJsonStatus.geo.coordinates[0];
                status.geo_coordinates_y = oJsonStatus.geo.coordinates[1];
            }
            if (oJsonStatus.in_reply_to_status_id != null && oJsonStatus.in_reply_to_status_id != "")
            {
                status.in_reply_to_status_id = Convert.ToInt64(oJsonStatus.in_reply_to_status_id);
            }
            if (oJsonStatus.in_reply_to_user_id != null && oJsonStatus.in_reply_to_user_id != "")
            {
                status.in_reply_to_user_id = Convert.ToInt64(oJsonStatus.in_reply_to_user_id);
            }
            status.in_reply_to_screen_name = oJsonStatus.in_reply_to_screen_name;
            status.mid  = Convert.ToInt64(oJsonStatus.mid);
            status.user = oJsonStatus.user;
            if (status.user.created_at != null)
            {
                status.user.created_at = PubHelper.ParseDateTime(status.user.created_at);
            }
            if (oJsonStatus.retweeted_status != null)
            {
                status.retweeted_status            = new Status();
                status.retweeted_status.created_at = PubHelper.ParseDateTime(oJsonStatus.retweeted_status.created_at);
                status.retweeted_status.status_id  = Convert.ToInt64(oJsonStatus.retweeted_status.id);
                status.retweeted_status.content    = oJsonStatus.retweeted_status.text;
                if (oJsonStatus.retweeted_status.source != null)
                {
                    status.retweeted_status.source_url  = oJsonStatus.retweeted_status.source.Substring(9, oJsonStatus.retweeted_status.source.IndexOf("rel") - 11);
                    status.retweeted_status.source_name = oJsonStatus.retweeted_status.source.Substring(oJsonStatus.retweeted_status.source.IndexOf('>') + 1, oJsonStatus.retweeted_status.source.IndexOf("</") - oJsonStatus.retweeted_status.source.IndexOf('>') - 1);
                }
                status.retweeted_status.favorited = oJsonStatus.retweeted_status.favorited;
                status.retweeted_status.truncated = oJsonStatus.retweeted_status.truncated;
                if (oJsonStatus.retweeted_status.geo != null)
                {
                    status.retweeted_status.geo_type          = oJsonStatus.retweeted_status.geo.type.ToLower();
                    status.retweeted_status.geo_coordinates_x = oJsonStatus.retweeted_status.geo.coordinates[0];
                    status.retweeted_status.geo_coordinates_y = oJsonStatus.retweeted_status.geo.coordinates[1];
                }
                if (oJsonStatus.retweeted_status.in_reply_to_status_id != null && oJsonStatus.retweeted_status.in_reply_to_status_id != "")
                {
                    status.retweeted_status.in_reply_to_status_id = Convert.ToInt64(oJsonStatus.retweeted_status.in_reply_to_status_id);
                }
                if (oJsonStatus.retweeted_status.in_reply_to_user_id != null && oJsonStatus.retweeted_status.in_reply_to_user_id != "")
                {
                    status.retweeted_status.in_reply_to_user_id = Convert.ToInt64(oJsonStatus.retweeted_status.in_reply_to_user_id);
                }
                status.retweeted_status.in_reply_to_screen_name = oJsonStatus.retweeted_status.in_reply_to_screen_name;
                if (oJsonStatus.retweeted_status.mid != null && oJsonStatus.retweeted_status.mid.Trim() != "")
                {
                    status.retweeted_status.mid = Convert.ToInt64(oJsonStatus.retweeted_status.mid);
                }
                status.retweeted_status.user = oJsonStatus.retweeted_status.user;
                if (status.retweeted_status.user.created_at != null)
                {
                    status.retweeted_status.user.created_at = PubHelper.ParseDateTime(status.retweeted_status.user.created_at);
                }
            }
            //------------20120317加------------
            status.idstr          = oJsonStatus.idstr;
            status.reposts_count  = oJsonStatus.reposts_count;
            status.comments_count = oJsonStatus.comments_count;
            status.mlevel         = oJsonStatus.mlevel;
            if (oJsonStatus.visible != null)
            {
                status.visible_type    = oJsonStatus.visible.type;
                status.visible_list_id = oJsonStatus.visible.list_id;
            }
            //----------------------------------
            return(status);
        }
Exemple #3
0
 //transform a JsonStatus object to a Status object
 private Status JsonStatusToStatus(JsonStatus oJsonStatus)
 {
     Status status = new Status();
     status.created_at = PubHelper.ParseDateTime(oJsonStatus.created_at);
     status.status_id = oJsonStatus.id;
     status.content = oJsonStatus.text;
     if (oJsonStatus.source != null)
     {
         status.source_url = oJsonStatus.source.Substring(9, oJsonStatus.source.IndexOf("rel") - 11);
         status.source_name = oJsonStatus.source.Substring(oJsonStatus.source.IndexOf('>') + 1, oJsonStatus.source.IndexOf("</") - oJsonStatus.source.IndexOf('>') - 1);
     }
     status.favorited = oJsonStatus.favorited;
     status.truncated = oJsonStatus.truncated;
     if (oJsonStatus.geo != null)
     {
         status.geo_type = oJsonStatus.geo.type.ToLower();
         status.geo_coordinates_x = oJsonStatus.geo.coordinates[0];
         status.geo_coordinates_y = oJsonStatus.geo.coordinates[1];
     }
     if (oJsonStatus.in_reply_to_status_id != null && oJsonStatus.in_reply_to_status_id != "")
         status.in_reply_to_status_id = Convert.ToInt64(oJsonStatus.in_reply_to_status_id);
     if (oJsonStatus.in_reply_to_user_id != null && oJsonStatus.in_reply_to_user_id != "")
         status.in_reply_to_user_id = Convert.ToInt64(oJsonStatus.in_reply_to_user_id);
     status.in_reply_to_screen_name = oJsonStatus.in_reply_to_screen_name;
     status.mid = Convert.ToInt64(oJsonStatus.mid);
     status.user = oJsonStatus.user;
     if (status.user.created_at != null)
         status.user.created_at = PubHelper.ParseDateTime(status.user.created_at);
     if (oJsonStatus.retweeted_status != null)
     {
         status.retweeted_status = new Status();
         status.retweeted_status.created_at = PubHelper.ParseDateTime(oJsonStatus.retweeted_status.created_at);
         status.retweeted_status.status_id = Convert.ToInt64(oJsonStatus.retweeted_status.id);
         status.retweeted_status.content = oJsonStatus.retweeted_status.text;
         if (oJsonStatus.retweeted_status.source != null)
         {
             status.retweeted_status.source_url = oJsonStatus.retweeted_status.source.Substring(9, oJsonStatus.retweeted_status.source.IndexOf("rel") - 11);
             status.retweeted_status.source_name = oJsonStatus.retweeted_status.source.Substring(oJsonStatus.retweeted_status.source.IndexOf('>') + 1, oJsonStatus.retweeted_status.source.IndexOf("</") - oJsonStatus.retweeted_status.source.IndexOf('>') - 1);
         }
         status.retweeted_status.favorited = oJsonStatus.retweeted_status.favorited;
         status.retweeted_status.truncated = oJsonStatus.retweeted_status.truncated;
         if (oJsonStatus.retweeted_status.geo != null)
         {
             status.retweeted_status.geo_type = oJsonStatus.retweeted_status.geo.type.ToLower();
             status.retweeted_status.geo_coordinates_x = oJsonStatus.retweeted_status.geo.coordinates[0];
             status.retweeted_status.geo_coordinates_y = oJsonStatus.retweeted_status.geo.coordinates[1];
         }
         if (oJsonStatus.retweeted_status.in_reply_to_status_id != null && oJsonStatus.retweeted_status.in_reply_to_status_id != "")
             status.retweeted_status.in_reply_to_status_id = Convert.ToInt64(oJsonStatus.retweeted_status.in_reply_to_status_id);
         if (oJsonStatus.retweeted_status.in_reply_to_user_id != null && oJsonStatus.retweeted_status.in_reply_to_user_id != "")
             status.retweeted_status.in_reply_to_user_id = Convert.ToInt64(oJsonStatus.retweeted_status.in_reply_to_user_id);
         status.retweeted_status.in_reply_to_screen_name = oJsonStatus.retweeted_status.in_reply_to_screen_name;
         if (oJsonStatus.retweeted_status.mid != null && oJsonStatus.retweeted_status.mid.Trim() != "")
             status.retweeted_status.mid = Convert.ToInt64(oJsonStatus.retweeted_status.mid);
         status.retweeted_status.user = oJsonStatus.retweeted_status.user;
         if (status.retweeted_status.user.created_at != null)
             status.retweeted_status.user.created_at = PubHelper.ParseDateTime(status.retweeted_status.user.created_at);
     }
     //------------20120317加------------
     status.idstr = oJsonStatus.idstr;
     status.reposts_count = oJsonStatus.reposts_count;
     status.comments_count = oJsonStatus.comments_count;
     status.mlevel = oJsonStatus.mlevel;
     if (oJsonStatus.visible != null)
     {
         status.visible_type = oJsonStatus.visible.type;
         status.visible_list_id = oJsonStatus.visible.list_id;
     }
     //----------------------------------
     return status;
 }