Exemple #1
0
        public void sendWeiboText(Weibo weibo)
        {
            string        url     = API_SER + WEIBO_TEXT;
            StringBuilder builder = new StringBuilder();

            builder.Append("access_token").Append(mToken);
            string data = "access_token=" + mToken + "&status=" + weibo.Text;

            mRequest.PostData(url, data, "");
        }
Exemple #2
0
        public List <Weibo> getWeiboList(params string[] args)
        {
            #region request arg
            StringBuilder builder = new StringBuilder();
            builder.Append(API_SER).Append(WEIBO_LIST).Append("?access_token=").Append(mToken);
            int argsIndex = 0;
            if (args.Length > argsIndex && args[argsIndex] != null)
            {
                builder.Append("&uid=").Append(args[argsIndex]);
            }
            argsIndex++;
            if (args.Length > argsIndex && args[argsIndex] != null)
            {
                builder.Append("&screen_names=").Append(args[argsIndex]);
            }
            argsIndex++;
            if (args.Length > argsIndex && args[argsIndex] != null)
            {
                builder.Append("&count=").Append(args[argsIndex]);
            }
            argsIndex++;
            if (args.Length > argsIndex && args[argsIndex] != null)
            {
                builder.Append("&page=").Append(args[argsIndex]);
            }
            argsIndex++;
            if (args.Length > argsIndex && args[argsIndex] != null)
            {
                builder.Append("&base_app=").Append(args[argsIndex]);
            }
            argsIndex++;
            if (args.Length > argsIndex && args[argsIndex] != null)
            {
                builder.Append("&feature=").Append(args[argsIndex]);
            }
            argsIndex++;
            #endregion

            List <Weibo> rel = null;
            try
            {
                string   json = mRequest.GetData(builder.ToString());
                JSONNode node = JSON.Parse(json);
                rel = new List <Weibo>();

                foreach (JSONNode item in node["statuses"].AsArray)
                {
                    Weibo data = new Weibo();
                    data.Mid       = item["mid"];
                    data.Text      = item["text"];
                    data.TimeStamp = item["created_at"];
                    rel.Add(data);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
            return(rel);
        }