コード例 #1
0
        /// <summary>
        /// Get All Direct Messages Of User.
        /// </summary>
        /// <param name="OAuth">OAuth Keys Token, TokenSecret, ConsumerKey, ConsumerSecret</param>
        /// <param name="Count">Number Of Direct Messages</param>
        /// <returns>Return List Of DirectMessage</returns>
        public List<direct_messages> GetDirectMessages(oAuthTwitter OAuth, string Count, SortedDictionary<string, string> strdic)
        {
            direct_messages direct_Messages = new direct_messages();

            Twitter.Core.DirectMessageMethods.DirectMessage directMessage = new Twitter.Core.DirectMessageMethods.DirectMessage();
            xmlResult = directMessage.DirectMessages(OAuth, Count);
            XmlNodeList xmlNodeList = xmlResult.GetElementsByTagName("direct_message");

            foreach (XmlNode xn in xmlNodeList)
            {
                XmlElement idElement = (XmlElement)xn;
                direct_Messages.Id = idElement.GetElementsByTagName("id")[0].InnerText;

                XmlElement sender_idElement = (XmlElement)xn;
                direct_Messages.sender_id = sender_idElement.GetElementsByTagName("sender_id")[0].InnerText;

                XmlElement created_atElement = (XmlElement)xn;
                direct_Messages.created_at = created_atElement.GetElementsByTagName("created_at")[0].InnerText;

                XmlElement sender_screen_nameElement = (XmlElement)xn;
                direct_Messages.sender_screen_name = sender_screen_nameElement.GetElementsByTagName("sender_screen_name")[0].InnerText;

                XmlElement recipient_screen_nameElement = (XmlElement)xn;
                direct_Messages.recipient_screen_name = recipient_screen_nameElement.GetElementsByTagName("recipient_screen_name")[0].InnerText;

                XmlElement textElement = (XmlElement)xn;
                direct_Messages.Description = textElement.GetElementsByTagName("text")[0].InnerText;

                XmlElement screenNameElement = (XmlElement)xn;
                direct_Messages.senderObject.ScreenName = screenNameElement.GetElementsByTagName("screen_name")[0].InnerText;

                XmlElement imageUrlElement = (XmlElement)xn;
                direct_Messages.senderObject.ProfileImageUrl = new Uri(imageUrlElement.GetElementsByTagName("profile_image_url")[0].InnerText);

                XmlElement followersCountElement = (XmlElement)xn;
                direct_Messages.senderObject.FollowersCount = int.Parse(followersCountElement.GetElementsByTagName("followers_count")[0].InnerText);

                XmlElement friendCountElement = (XmlElement)xn;
                direct_Messages.senderObject.FriendsCount = int.Parse(friendCountElement.GetElementsByTagName("friends_count")[0].InnerText);

                XmlElement statusElement = (XmlElement)xn;
                direct_Messages.senderObject.StatusesCount = int.Parse(statusElement.GetElementsByTagName("statuses_count")[0].InnerText);

                DirectMessages.Add(direct_Messages);
            }
            return DirectMessages;

        }