Exemple #1
0
 public SinaWBOauth()
 {
     InitializeComponent();
     app_key    = "906953775";
     app_secret = "67c042f6ccd8ba4d7e592566b53b3bc5";
     util.XmlUtil xmlutil = new util.XmlUtil();
     callback_url = xmlutil.GetValue("CallbackUrl");
     access_token = xmlutil.GetValue("AccessToken");
 }
Exemple #2
0
        string callback_url = ""; //System.Configuration.ConfigurationSettings.AppSettings["CallbackUrl"];

        #endregion Fields

        #region Constructors

        public SinaWBOauth()
        {
            InitializeComponent();
            app_key = "906953775";
            app_secret = "67c042f6ccd8ba4d7e592566b53b3bc5";
            util.XmlUtil xmlutil = new util.XmlUtil();
            callback_url = xmlutil.GetValue("CallbackUrl");
            access_token = xmlutil.GetValue("AccessToken");
        }
Exemple #3
0
        public SinaWeibo(int rate)
        {
            app_key = "906953775";
            app_secret = "67c042f6ccd8ba4d7e592566b53b3bc5";
            callback_url = xmlutil.GetValue("CallbackUrl");
            access_token = xmlutil.GetValue("AccessToken");

            //取得授权过的新浪客户端,给全局变量sina赋值
            getSinaClient();

            //设置间隔时间为120秒
            t = new System.Timers.Timer(rate);
            //构造方法里面定义多线程计时器
            t.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            //设置是执行一次(false)还是一直执行(true)
            t.AutoReset = true;
            //是否执行System.Timers.Timer.Elapsed事件
            t.Enabled = true;
        }
Exemple #4
0
 private void HiddenSinaWBOauth_Load(object sender, EventArgs e)
 {
     //如果没有用户授权文件,则直接退出。
     if (!File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Web.Smtp.dll"))
     {
         oauth2result = true;
         this.Close();
     }
     else
     {
         callback_url = xmlutil.GetValue("CallbackUrl");
         string url = "https://api.weibo.com/oauth2/authorize?client_id="
                      + app_key
                      + "&response_type=code&redirect_uri="
                      + callback_url;
         webBrowser1.Url = new Uri(url);
     }
 }
Exemple #5
0
        string weibo_ids = "";  //含有关键字的微博ids

        public QQWeibo(int rate)
        {
            appKey       = "801426797";
            appSecret    = "0e9382190a5f764b57e09c15cda96e09";
            accessToken  = xmlUtil.GetValue("QQWbAccessToken");
            openId       = xmlUtil.GetValue("QQWbOpenId");
            callBackUrl  = xmlUtil.GetValue("QQWbCallbackUrl");
            openKey      = xmlUtil.GetValue("QQWbOpenKey");
            RefreshToken = xmlUtil.GetValue("QQWbRefreshToken");
            expire_in    = xmlUtil.GetValue("QQWbExpire_in");
            fetchDateStr = xmlUtil.GetValue("QQWbFetchAccessTokenDate");

            timer           = new System.Timers.Timer(rate);
            timer.AutoReset = true;
            timer.Elapsed  += new ElapsedEventHandler(timer_Elapsed);
            if (string.IsNullOrEmpty(accessToken) || string.IsNullOrEmpty(openKey) || string.IsNullOrEmpty(openId) || string.IsNullOrEmpty(RefreshToken) || string.IsNullOrEmpty(expire_in) || string.IsNullOrEmpty(fetchDateStr))
            {
                if (MessageBox.Show("腾讯微博未授权或授权已过期,请在系统设置中进行授权!", "注意", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
                {
                    Finder.QQWeibo weibo = new Finder.QQWeibo();
                    if (weibo.ShowDialog() == DialogResult.OK)
                    {
                        accessToken  = xmlUtil.GetValue("QQWbAccessToken");
                        openId       = xmlUtil.GetValue("QQWbOpenId");
                        callBackUrl  = xmlUtil.GetValue("QQWbCallbackUrl");
                        openKey      = xmlUtil.GetValue("QQWbOpenKey");
                        RefreshToken = xmlUtil.GetValue("QQWbRefreshToken");
                        expire_in    = xmlUtil.GetValue("QQWbExpire_in");
                        fetchDateStr = xmlUtil.GetValue("QQWbFetchAccessTokenDate");
                    }
                }
            }
            timer.Enabled = false;
        }