Exemplo n.º 1
0
        //transform a JsonComment object to a Comment object
        private Comment JsonCommentToComment(JsonComment oJsonComment)
        {
            Comment comment = new Comment();

            comment.comment_id = oJsonComment.id;
            comment.content    = oJsonComment.text;
            comment.created_at = PubHelper.ParseDateTime(oJsonComment.created_at);
            comment.idstr      = oJsonComment.idstr;
            if (oJsonComment.mid != null && oJsonComment.mid.Trim() != "")
            {
                comment.mid = Convert.ToInt64(oJsonComment.mid);
            }
            if (oJsonComment.source != null)
            {
                comment.source_url  = oJsonComment.source.Substring(9, oJsonComment.source.IndexOf("rel") - 11);
                comment.source_name = oJsonComment.source.Substring(oJsonComment.source.IndexOf('>') + 1, oJsonComment.source.IndexOf("</") - oJsonComment.source.IndexOf('>') - 1);
            }
            if (oJsonComment.status != null)
            {
                comment.status_id = oJsonComment.status.id;
            }
            comment.user = oJsonComment.user;
            if (oJsonComment.reply_comment != null)
            {
                comment.reply_comment = JsonCommentToComment(oJsonComment.reply_comment);
            }

            return(comment);
        }
Exemplo n.º 2
0
        //同时根据UserID和用户昵称抓取用户信息
        public User GetUserInfo(long lUid, string strScreenName)
        {
            System.Threading.Thread.Sleep(iSleep);
            User user = api.API.Users_Show(lUid, strScreenName);

            if (user == null && api.API.JsonResult.Contains("400"))    //用户不存在
            {
                return(null);
            }
            if (user == null && api.API.JsonResult.Contains("403"))    //服务已禁止
            {
                user         = new User();
                user.user_id = -1;
            }
            user.created_at = PubHelper.ParseDateTime(user.created_at);
            return(user);
        }
Exemplo n.º 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);
        }