Esempio n. 1
0
        private static void NormalizeAccount()
        {
            string[] acc = File.ReadAllLines("moreAccount.txt");
            foreach (var st in acc)
            {
                string[] tmp = st.Split(' ');
                string   username = tmp[0], password = tmp[1];

                OAuth o = new OAuth(DefaultSettings.AppKey, DefaultSettings.AppSecret, String.Empty);
                o.ClientLogin(username, password);
                Client client = new Client(o);

                try
                {
                    var s          = client.API.Entity.Account.GetUID();
                    var collection = WeiboAPI.GetFriendsIDs(s, Enums.SampleMethod.All);
                    foreach (var id in collection)
                    {
                        client.API.Entity.Friendships.Destroy(id);
                        Thread.Sleep(1000);
                    }
                    Console.WriteLine(username + " successed");
                    File.AppendAllText("accountResult.txt", username + " " + password + '\n');
                }
                catch (WeiboException ex)
                {
                    Console.WriteLine(username + " " + ex.ErrorCode + " " + ex.ErrorMessage);
                }
                Thread.Sleep(9000);
            }
        }
Esempio n. 2
0
        private static bool ClientLogin(OAuth o)
        {
            string passport = Properties.WeiboOAuth.Default.WeiboUser;
            string password = Properties.WeiboOAuth.Default.WeiboPassword;

            Console.WriteLine("username:"******"password:"******"******");

            return(o.ClientLogin(passport, password));
        }
Esempio n. 3
0
        static OAuth Authorize(string passport, string password)
        {
            OAuth o = new OAuth(Properties.Settings.Default.Appkey, Properties.Settings.Default.AppSecrect, Properties.Settings.Default.CallbackUrl);

            if (!o.ClientLogin(passport, password))
            {
                throw new Exception("认证失败");
            }
            return(o);
        }
Esempio n. 4
0
        private void btnSendToWeibo_Click(object sender, EventArgs e)
        {
            OAuth  oauth    = new OAuth(appKey, appSecrect, callbackUrl);
            string passport = this.txtName.Text.Trim();
            string password = this.txtPwd.Text.Trim();


            //string accessToken = string.Empty;
            bool result = oauth.ClientLogin(passport, password);

            if (!result)
            {
                MessageBoxHelper.Show("微博登陆失败!");
                return;
            }



            //好吧,授权至此应该成功了。下一步调用接口吧。
            Client Sina = new Client(oauth);

            try
            {
                //.Net其他版本
                string uid = Sina.API.Account.GetUID(); //获取UID
                //这里用VS2010的var关键字和可选参数最惬意了。
                //如果用VS2005什么的你得这样写:
                //NetDimension.Weibo.Entities.user.Entity userInfo = Sina.API.Users.Show(uid,null);
                //如果用VS2008什么的也不方便,你得把参数写全:
                //var userInfo = Sina.API.Users.Show(uid,null);
                var userInfo = Sina.API.Users.Show(uid, null);
                Console.WriteLine("昵称:{0}", userInfo.ScreenName);
                Console.WriteLine("来自:{0}", userInfo.Location);

                //发条微博啥的

                Image img = this.imageProcessPanel1.GetFinalImage();


                //var statusInfo = Sina.API.Statuses.Update(string.Format("我是{0},我来自{1},我在{2}用《新浪微博开放平台API for .Net SDK》开发了一个小程序并发了这条微博,欢迎关注http://weibosdk.codeplex.com/", userInfo.ScreenName, userInfo.Location, DateTime.Now.ToShortTimeString()),0,0,"");
                var statusInfo = Sina.API.Statuses.Upload("测试内容" + System.DateTime.Now.ToLocalTime().ToString(), ImageHelper.GetBytesByImage(img), 0, 0, "");
                //加个当前时间防止重复提交报错。

                Console.WriteLine("微博已发送,发送时间:{0}", statusInfo.CreatedAt);
                MessageBoxHelper.Show("微博已发送");
            }
            catch (WeiboException ex)
            {
                Console.WriteLine("出错啦!" + ex.Message);
                MessageBoxHelper.Show("出错啦!" + ex.Message);
            }

            Console.WriteLine("演示结束,按任意键继续...");
        }
Esempio n. 5
0
        private static bool ClientLogin(OAuth o)
        {
            //Console.Write("微博账号:");
            string passport = "*****@*****.**";
            //Console.Write("登录密码:");

            //ConsoleColor originColor = Console.ForegroundColor;
            //Console.ForegroundColor = Console.BackgroundColor; //知道这里是在干啥不?其实是为了不让你们看到我的密码^_^

            string password = "******";

            //Console.ForegroundColor = originColor; //恢复前景颜色。

            return(o.ClientLogin(passport, password));
        }
Esempio n. 6
0
 /// <summary>
 /// 获取特定的僵尸以执行任务,如订阅、关注等
 /// </summary>
 /// <param name="username">僵尸用户名</param>
 /// <returns>特定僵尸Client</returns>
 private static Client GetSpecificClient(string username)
 {
     lock (clientCacheLock)
     {
         if (clientCache.ContainsKey(username))
         {
             return(clientCache[username]);
         }
         string password = AccountDBManager.GetPassword(username);
         RequireAccPermission(3);
         OAuth o = new OAuth(DefaultSettings.AppKey, DefaultSettings.AppSecret, String.Empty);
         o.ClientLogin(username, password);
         Client client = new Client(o);
         clientCache.Add(username, client);
         return(client);
     }
 }
Esempio n. 7
0
        static void Main(string[] args)
        {
            //新浪微博SDK for .net 2.0/3.5/4.0
            //之前专门针对.net4.0动态类型特性的版本在未来的release中会同时支持返回dynamic和实体类
            OAuth oauth = new OAuth("AppKey", "AppSecret");

            var result = oauth.ClientLogin("<账号>", "<密码>", "<绑定的回调地址>");

            //标准授权及登录流程请下载前面提供的DEMO程序查看。
            if (result)
            {
                try
                {
                    var Sina = new Client(oauth);

                    //NetDimension.Weibo.Entities.RateLimitStatus limit = Sina.API.Account.RateLimitStatus();
                    var limit = Sina.API.Account.RateLimitStatus();//与之前返回dynamic相比,这个版本返回了实体类型
                    Console.WriteLine("======= 用量 =======");
                    Console.WriteLine("IPLimit:{0}", limit.IPLimit);
                    Console.WriteLine("RemainingIPHits:{0}", limit.RemainingIPHits);
                    Console.WriteLine("RemainingUserHits:{0}", limit.RemainingUserHits);
                    Console.WriteLine("ResetTime:{0}", limit.ResetTime);
                    Console.WriteLine("UserLimit:{0}", limit.UserLimit);
                    //发布一条微博看看
                    var status = Sina.API.Statuses.Update(string.Format("这条测试微博在{0}发自《新浪微博SDK for .Net 2.0/3.5/4.0》,由新浪网云南频道技术部林选臣开发制作,欢迎下载试用。下载地址:http://weibosdk.codeplex.com", DateTime.Now.ToString()));
                    //返回的status类型为NetDimension.Weibo.Entities.status.Entity
                    //在这里设置一个断点,看看status吧^_^

                    Console.WriteLine("======= 微博结果 =======");
                    Console.WriteLine("ID:{0}", status.ID);
                    Console.WriteLine("MID:{0}", status.MID);
                }
                catch (WeiboException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.ReadKey();
        }
Esempio n. 8
0
        private static void TestAccount()
        {
            string[] acc = File.ReadAllLines("1111.txt");
            foreach (var st in acc)
            {
                string[] tmp = st.Split(',');
                string   username = tmp[0], password = tmp[1];

                OAuth o = new OAuth(DefaultSettings.AppKey, DefaultSettings.AppSecret, String.Empty);
                o.ClientLogin(username, password);
                Client client = new Client(o);
                try
                {
                    var s = client.API.Entity.Friendships.Create("1266321801");
                    Console.WriteLine(username + " " + s.Name);
                    File.AppendAllText("accountResult.txt", username + " " + password + '\n');
                }
                catch (WeiboException ex)
                {
                    Console.WriteLine(username + " " + ex.ErrorCode + " " + ex.ErrorMessage);
                }
                Thread.Sleep(10000);
            }
        }
Esempio n. 9
0
 public static bool ClientLogin(OAuth oauth, string Account, string password)
 {
     return(oauth.ClientLogin(Account, password));
 }
Esempio n. 10
0
 private static bool ClientLogin(OAuth o)
 {
     return(o.ClientLogin(passport, password));
 }