Example #1
0
        private void wc_openHandler_facebook(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string jsonstr = e.Result.ToString();
                JObject obj = JObject.Parse(jsonstr);
                JArray items = (JArray)obj["notifications"];

                if (items != null)
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        JObject item = (JObject)items[i];
                        NotifiView list = new NotifiView();
                        list.id = (string)item["object_id"];
                        list.type = "facebook.png";
                        list.text = (string)item["title_text"];
                        list.dtime = ConvertTimestamp((long)item["created_time"]);
                        list.thumb_img = string.Format("http://graph.facebook.com/{0}/picture", item["sender_id"].ToString());
                        lists.Add(list);
                        if (i > 9)
                            break;
                    }
                }
                fr_chk = true;
                check_end();
            }
        }
Example #2
0
        private void wc_openHandler_me2day(IAsyncResult asynchronousResult)
        {
            try
            {
                WebResponse response = ((HttpWebRequest)asynchronousResult.AsyncState).EndGetResponse(asynchronousResult);
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string responseString = reader.ReadToEnd();

                reader.Close();
                var dom = XDocument.Parse(responseString);

                var items = from item in dom.Descendants("commentToMe")
                            select new Me2View
                            {
                                id = (string)item.Element("post").Element("post_id").Value,
                                name = (string)item.Element("comment").Element("author").Element("nickname").Value,
                                text = (string)item.Element("comment").Element("body").Value,
                                tag = (string)item.Element("post").Element("body"),
                                dtime = (DateTime)item.Element("comment").Element("pubDate"),
                                thumb_img = (string)item.Element("comment").Element("author").Element("face"),
                            };

                int i = 0;
                foreach (Me2View item in items)
                {
                    i++;
                    NotifiView list = new NotifiView();
                    list.id = item.id;
                    list.type = "me2day.png";
                    list.text = HtmlRemoval.StripTagsRegexCompiled(item.text);
                    list.text = list.text.Replace("&lt;", "<");
                    list.text = list.text.Replace("&gt;", ">");
                    list.thumb_img = item.thumb_img;
                    list.dtime = item.dtime;
                    lists.Add(list);
                    if (i > 9)
                        break;
                }
                mr_chk = true;
                check_end();
            }
            catch (WebException ex)
            {

            }
        }
Example #3
0
        private void start_update()
        {
            tr_chk = false;
            fr_chk = false;
            mr_chk = false;
            lists = new List<NotifiView>();
            if (t_chk == true)
            {
                TwitterService service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q");
                service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]);
                service.ListTweetsMentioningMe(0, 10,
                        (tweets, response) =>
                        {
                            if (response.StatusCode == HttpStatusCode.OK)
                            {
                                tr_chk = true;
                                foreach (var tweet in tweets)
                                {
                                    NotifiView list = new NotifiView();
                                    list.name = tweet.Author.ScreenName;
                                    list.id = tweet.Id.ToString();
                                    list.type = "twitter.png";
                                    list.thumb_img = tweet.User.ProfileImageUrl;
                                    list.text = tweet.Text;
                                    list.dtime = tweet.CreatedDate.ToLocalTime();
                                    Dispatcher.BeginInvoke(delegate()
                                    {
                                        lists.Add(list);
                                    });
                                }
                                Dispatcher.BeginInvoke(delegate()
                                {
                                    check_end();
                                });
                            }

                        });

            }

            if (f_chk == true)
            {
                string url = String.Format("https://api.facebook.com/method/notifications.getList?access_token={0}&format=json", (string)settings["facebook_token"]);
                WebClient wc = new WebClient();
                wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler_facebook);
                wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
            }

            if (m_chk == true)
            {
                string url = String.Format("http://me2day.net/api/track_comments/{0}.xml?akey=aed420d038f9b1a7fe3b5c0d94df22f5&scope=to_me&count=10", (string)settings["me2day_userid"]);
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
                webRequest.Method = "POST";

                string auth_key = String.Format("full_auth_token {0}", settings["me2day_token"]);
                webRequest.Credentials = new NetworkCredential((string)settings["me2day_userid"], auth_key);
                IAsyncResult token = webRequest.BeginGetResponse(new AsyncCallback(wc_openHandler_me2day), webRequest);
            }
        }