コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var httpRequest = HttpRequestFactory.CreateHttpRequest(Method.GET) as HttpGet;
        if (Request["oauth_verifier"] != null)
        {
            string user_id = "";
            httpRequest.Token = Session["oauth_token"].ToString();
            httpRequest.TokenSecret = Session["oauth_token_secret"].ToString();
            httpRequest.Verifier = Request["oauth_verifier"];
            httpRequest.GetAccessToken(out user_id);
            Session["oauth_token"] = httpRequest.Token;
            Session["oauth_token_secret"] = httpRequest.TokenSecret;
            Session["Sina_user_id"] = user_id;

            DictEntity dt = new DictEntity();
            dt.App = "Sina";
            dt.UserID = user_id;
            dt.Key = "Token";
            dt.Value = httpRequest.Token;
            Dict.Save(dt);
            dt.Key = "TokenSecret";
            dt.Value = httpRequest.TokenSecret;
            Dict.Save(dt);
            //T.SaveRelation();
            //Response.Write(httpRequest.TokenSecret);
            Response.Redirect("Mi.aspx");
        }
    }
コード例 #2
0
ファイル: SB.aspx.cs プロジェクト: cvs1989/hooyeswidget
    protected void initPage()
    {
        string json = "";
        if (Session["QQ_user_id"] != null)
        {
            DictEntity dt = new DictEntity();
            dt.App = "QQ";
            dt.UserID = Convert.ToString(Session["QQ_user_id"]);
            dt.Key = Convert.ToString(Session["QQ_user_id"]);
            //dt.Value = TextBox1.Text;

            string v = Dict.Get<string>(dt);
            json = "isLogin:{1},love:'{0}'";
            json = string.Format(json, v, "true");
        }
        else
        {
            json = "isLogin:{1},love:'{0}'";
            json = string.Format(json, "", "false");
        }
        json = "{" + json + "}";
        string script = @"<script>
         var json={0};
        </script>";
        script = string.Format(script, json);
        ClientScript.RegisterClientScriptBlock(this.GetType(), "xx", script);
    }
コード例 #3
0
ファイル: SB.aspx.cs プロジェクト: cvs1989/hooyeswidget
    protected void BtnSumbit_Click(object sender, EventArgs e)
    {
        DictEntity dt = new DictEntity();
        dt.App = "QQ";
        dt.UserID = Convert.ToString(Session["QQ_user_id"]);
        dt.Key = Convert.ToString(Session["QQ_user_id"]);
        dt.Value = TextBox1.Text.Replace("'", "");

        Dict.Save(dt);

        Response.Redirect("SB.aspx");
    }
コード例 #4
0
ファイル: CB_QQ_Mi.aspx.cs プロジェクト: cvs1989/hooyeswidget
    protected void Page_Load(object sender, EventArgs e)
    {
        string verifier = Request.QueryString.Get("oauth_verifier");
        if (!string.IsNullOrEmpty(verifier))
        {
            string appKey = Constant.app_key_QQ;
            string appSecret = Constant.app_secret_QQ;
            OAuth oauth = new OAuth(appKey, appSecret);
            string name;
            oauth.Token = (string)Session["QQ_oauth_token"];
            oauth.TokenSecret = (string)Session["QQ_oauth_token_secret"];
            if (oauth.GetAccessToken(verifier, out name))
            {
                Session["QQ_oauth_token"] = oauth.Token;
                Session["QQ_oauth_token_secret"] = oauth.TokenSecret;
                Session["QQ_user_id"] = name;

                DictEntity dt = new DictEntity();
                dt.App = "QQ";
                dt.UserID = name;
                dt.Key = "Token";
                dt.Value = oauth.Token;
                Dict.Save(dt);
                dt.Key = "TokenSecret";
                dt.Value = oauth.TokenSecret;
                Dict.Save(dt);

                ////MaxTimeline
                //Timeline api = new Timeline(oauth);
                //var data = api.GetBroadcast_timeline(PageFlag.First, 0, 1);
                //if (data.Tweets.Length > 0)
                //{
                //    OpenTSDK.Tencent.Objects.Tweet tw = data.Tweets[0];
                //    if (tw.Timestamp > 0)
                //    {
                //        DictEntity dtT = new DictEntity();
                //        dtT.App = "QQ";
                //        dtT.Key = "MaxTimeline";
                //        dtT.UserID = name;
                //        dtT.Value = tw.Timestamp.ToString();
                //        Dict.Save(dtT);
                //    }
                //}

                //T.SaveRelation();

                //Response.Write(oauth.TokenSecret);
                Response.Redirect("SB.aspx");
            }

        }
    }
コード例 #5
0
ファイル: Program.cs プロジェクト: cvs1989/hooyeswidget
        static void Test1()
        {
            DictEntity dt = new DictEntity();
            dt.App = "QQ";
            dt.Key = "MaxTimeline";
            dt.UserID = "q83623011";
            dt.Value = "1303235118";
            Dict.Save(dt);

            string s= Dict.Get<string>(dt);
            Console.Write(s);
            Console.Read();
        }
コード例 #6
0
ファイル: Mi.aspx.cs プロジェクト: cvs1989/hooyeswidget
    protected void initPage()
    {
        string json = "";
        if (Session["Sina_user_id"] != null)
        {
            DictEntity dt = new DictEntity();
            dt.App = "Sina";
            dt.UserID = Convert.ToString(Session["Sina_user_id"]);
            dt.Key = Convert.ToString(Session["Sina_user_id"]);
            //dt.Value = TextBox1.Text;

            string v = Dict.Get<string>(dt);
            json = "isLogin:{1},love:'{0}'";
            json = string.Format(json, v,"true");
        }
        else
        {
            json = "isLogin:{1},love:'{0}'";
            json = string.Format(json,"","false");
        }
        json = "{" + json + "}";
        string script = @"<script>
         var json={0};
        </script>";
        script = string.Format(script, json);
        ClientScript.RegisterClientScriptBlock(this.GetType(), "xx", script);

        if (HttpContext.Current.Session["Sina_user_id"] != null)
        {

            var httpRequest = HttpRequestFactory.CreateHttpRequest(Method.POST);
            httpRequest.Token = Convert.ToString(Session["oauth_token"]);
            httpRequest.TokenSecret = Convert.ToString(Session["oauth_token_secret"]);
            string url = "http://api.t.sina.com.cn/users/show.json?";
            string r = httpRequest.Request(url, "id=" + (string)HttpContext.Current.Session["Sina_user_id"]);
            string script2 = @"<script>
                  var sina={0};
                </script>";
            script2 = string.Format(script2, r);
            ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "Sina", script2);
        }
    }
コード例 #7
0
ファイル: Task.cs プロジェクト: cvs1989/hooyeswidget
        public static void Run()
        {
            try
               {
               //实例化OAuth对象
               string appKey = Constant.app_key_QQ;
               string appSecret = Constant.app_secret_QQ;

               List<RelationEntity> lt = Relation.Get();

               foreach (RelationEntity rt in lt)
               {
                   #region  单个用户
                   try
                   {
                       Dictionary<string, string> Main = new Dictionary<string, string>();
                       Dictionary<string, string> Sub = new Dictionary<string, string>();

                       Main = Dict.Get(rt.App, rt.UserID);
                       Sub = Dict.Get(rt.SubApp, rt.SubUserID);

                       OAuth oauth = new OAuth(appKey, appSecret);
                       oauth.Token = Main["Token"];// //"91c8a7555f694dd3bd7a55178dfa952d";            //Access Token
                       oauth.TokenSecret = Main["TokenSecret"];// "2e01aa675faf5764d59564537f142f51";      //Access Secret

                       Timeline api = new Timeline(oauth);
                       //各取数据出来
                       long maxTimeline = Main.ContainsKey("MaxTimeline") ? (long)Convert.ToDecimal(Main["MaxTimeline"]) : 0;
                       decimal MaxId = Sub.ContainsKey("MaxId") ? Convert.ToDecimal(Sub["MaxId"]) : 0;
                       TimelineData data = null;
                       try
                       {
                           data = api.GetBroadcast_timeline(PageFlag.First, 0, Constant.QQRequestNum);
                       }
                       catch (Exception ex)
                       {
                           log.Warn("{4},{0},{1},{2},{3}", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);
                           log.Warn("{0},{1}", ex.Message, ex.StackTrace);
                           Console.WriteLine("-----");
                           Console.Write("{4},{0},{1},{2},{3},GetQQDataError", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);
                       }
                        XmlDocument sinaT = null;
                        try
                        {

                            sinaT = Task.GetSinaUserTimeline(Sub["Token"], Sub["TokenSecret"], MaxId.ToString());
                        }
                        catch (Exception ex)
                        {
                            log.Warn("{4},{0},{1},{2},{3}", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);
                            log.Warn("{0},{1}", ex.Message, ex.StackTrace);
                            Console.WriteLine("-----");
                            Console.Write("{4},{0},{1},{2},{3},GetSinaDataError", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);
                        }

                       long maxTimelineTemp = maxTimeline;
                       decimal MaxIdTemp = 0;
                       if (data != null)
                       {
                           try
                           {
                               #region QQ to Sina

                               if (data.Tweets.Length > 0)
                               {

                                   //Master
                                   DictEntity dt = new DictEntity();
                                   dt.App = rt.App;
                                   dt.Key = "MaxTimeline";
                                   dt.UserID = rt.UserID;

                                   DictEntity dt2 = new DictEntity();
                                   dt2.App = rt.SubApp;
                                   dt2.Key = "MaxId";
                                   dt2.UserID = rt.SubUserID;

                                   for (int i = data.Tweets.Length; i > 0; i--)
                                   {
                                       try
                                       {
                                           OpenTSDK.Tencent.Objects.Tweet tw = data.Tweets[i - 1];
                                           if (tw.Timestamp > maxTimeline)
                                           {
                                               string Token = Sub["Token"];
                                               string TokenSecret = Sub["TokenSecret"];
                                               decimal Tid = 0;
                                               string pic = string.Empty;
                                               //只发原创
                                               if (tw.Type == 1)
                                               {
                                                   if (string.IsNullOrEmpty(tw.Image))
                                                   {
                                                       Tid = Sina(tw.Origtext, Token, TokenSecret);
                                                   }
                                                   else
                                                   {
                                                       pic = GetHttpFile(tw.Image + "/2000");
                                                       if (!string.IsNullOrEmpty(pic))
                                                       {
                                                           Tid = Sina(tw.Origtext, Token, TokenSecret, pic);
                                                       }
                                                       else
                                                       {
                                                           Tid = Sina(tw.Origtext, Token, TokenSecret);
                                                       }
                                                   }
                                               }

                                               //dt.Value = tw.Timestamp.ToString();
                                               if (maxTimelineTemp < tw.Timestamp)
                                               {
                                                   maxTimelineTemp = tw.Timestamp;
                                               }
                                               if (MaxIdTemp < Tid)
                                               {
                                                   MaxIdTemp = Tid;
                                               }
                                           }
                                       }
                                       catch (Exception ex)
                                       {
                                           log.Warn("{4},{0},{1},{2},{3}", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);
                                           log.Warn("{0},{1}", ex.Message, ex.StackTrace);
                                           Console.Write(ex.Message);
                                           Console.Write("{4},{0},{1},{2},{3}", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);

                                       }
                                   }
                                   if (maxTimeline < maxTimelineTemp)
                                   {
                                       dt.Value = maxTimelineTemp.ToString();
                                       Dict.Save(dt);
                                   }
                                   if (MaxIdTemp > 0)
                                   {
                                       dt2.Value = MaxIdTemp.ToString();
                                       Dict.Save(dt2);
                                   }
                               }
                               #endregion
                           }
                           catch (Exception ex)
                           {
                               log.Warn("{0},{1}", ex.Message, ex.StackTrace);
                           }
                       }
                       #region Sina TO QQ

                       try
                       {
                           if (sinaT != null)
                           {
                               long maxTimelineTemp2 = maxTimelineTemp;
                               decimal MaxIdTemp2 = MaxIdTemp;
                               XmlNodeList x = sinaT.SelectNodes("/statuses/status");
                               if (x.Count > 0)
                               {
                                   DictEntity dt = new DictEntity();
                                   dt.App = rt.App;
                                   dt.Key = "MaxTimeline";
                                   dt.UserID = rt.UserID;

                                   DictEntity dt2 = new DictEntity();
                                   dt2.App = rt.SubApp;
                                   dt2.Key = "MaxId";
                                   dt2.UserID = rt.SubUserID;

                                   foreach (XmlNode xn in x)
                                   {
                                       decimal id = Util.GetXmlNodeValue<decimal>(xn.SelectSingleNode("id"));
                                       string text = Util.GetXmlNodeValue<string>(xn.SelectSingleNode("text"));

                                       string original_pic = string.Empty;
                                       try
                                       {
                                           original_pic = Util.GetXmlNodeValue<string>(xn.SelectSingleNode("original_pic"));

                                           if (!string.IsNullOrEmpty(original_pic))
                                           {
                                               original_pic = GetHttpFile(original_pic);
                                           }
                                       }
                                       catch (Exception ex)
                                       {
                                           log.Warn("{0},{1}", ex.Message, ex.StackTrace);
                                       }

                                       XmlNode retweeted_status = xn.SelectSingleNode("//retweeted_status");

                                       TweetOperateResult QQresult = null;
                                       //转播的不发啦
                                       if (retweeted_status == null)
                                       {
                                           QQresult = Task.QQ(text, Main["Token"], Main["TokenSecret"], original_pic);
                                           if (maxTimelineTemp2 < QQresult.Timestamp)
                                           {
                                               maxTimelineTemp2 = QQresult.Timestamp;
                                           }
                                       }

                                       if (MaxIdTemp2 < (long)id)
                                       {
                                           MaxIdTemp2 = id;
                                       }

                                   }
                                   if (maxTimelineTemp2 > maxTimelineTemp)
                                   {
                                       dt.Value = maxTimelineTemp2.ToString();
                                       Dict.Save(dt);
                                   }
                                   if (MaxIdTemp2 > MaxIdTemp)
                                   {
                                       dt2.Value = MaxIdTemp2.ToString();
                                       Dict.Save(dt2);
                                   }
                               }
                               //-----
                           }
                       }
                       catch (Exception ex)
                       {
                           log.Warn("{0},{1}", ex.Message, ex.StackTrace);
                       }
                       #endregion
                   }

                   catch (Exception ex)
                   {
                       Console.WriteLine(ex.Message);
                       log.Warn("{4},{0},{1},{2},{3}", rt.App, rt.UserID, rt.SubApp, rt.SubUserID, rt.ID);
                       log.Warn("{0},{1}", ex.Message, ex.StackTrace);

                   }

                   #endregion
               }
               }
               catch (Exception ex)
               {
               log.Warn("{0},{1}", ex.Message, ex.StackTrace);
               }
        }