コード例 #1
0
        public string GetSearch(OAuthData oAuthData)
        {
            var searchJson   = string.Empty;
            var authenticate = new Authenticate();
            TwitAuthenticateResponse twitAuthResponse = authenticate.AuthenticateMe(oAuthData.OAuthConsumerKey, oAuthData.OAuthConsumerSecret, OAuthUrl);

            // Do the timeline
            var utility = new Utility();

            searchJson = utility.RequstJson(searchUrl, twitAuthResponse.token_type, twitAuthResponse.access_token);

            return(searchJson);
        }
コード例 #2
0
        public TwitterData GetMyTimeline(string url, OAuthData oAuthData)
        {
            timelineUrl = url;
            var authenticate = new Authenticate();
            TwitAuthenticateResponse twitAuthResponse = authenticate.AuthenticateMe(oAuthData.OAuthConsumerKey, oAuthData.OAuthConsumerSecret, OAuthUrl);

            // Do the timeline
            var timeLineJson = new Utility().RequstJson(timelineUrl, twitAuthResponse.token_type, twitAuthResponse.access_token);

            TwitterData response = new TwitterData();

            response.xmls = new List <XmlDocument>();

            if (timeLineJson.StartsWith("Error:"))
            {
                response.error = timeLineJson;
                return(response);
            }

            //List<XmlDocument> xmls = new List<XmlDocument>();

            if (timeLineJson == string.Empty || timeLineJson == "[]")
            {
                return(response);
            }

            timeLineJson = timeLineJson.Substring(3, timeLineJson.Length - 6);
            var timeLines = timeLineJson.Split(new [] { "\"},{\"" }, System.StringSplitOptions.None);

            try
            {
                foreach (string line in timeLines)
                {
                    response.xmls.Add(JsonConvert.DeserializeXmlNode("{\"root\":[{\"" + line + "\"}]}"));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            return(response);
        }