コード例 #1
1
ファイル: HomeController.cs プロジェクト: nyxtom/tweetsharp
        public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
        {
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            var requestToken = new OAuthRequestToken {Token = oauth_token};

            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = service.VerifyCredentials();
            ViewModel.Message = string.Format("Your username is {0}", user.ScreenName);

            return View("Index");
        }
コード例 #2
0
        public void Can_get_reverse_geocode()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var places = service.ReverseGeocode(45.42153, -75.697193).ToList();
            Assert.IsNotEmpty(places);
            Assert.AreEqual(4, places.Count);

            places = places.OrderBy(p => p.Id).ToList();
            
            Assert.AreEqual("Ottawa, Ontario", places[0].FullName);
            Assert.AreEqual(TwitterPlaceType.City, places[0].PlaceType);
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
            Assert.AreEqual(1, places[0].ContainedWithin.Count());
            Assert.AreEqual("89b2eb8b2b9847f7", places[0].ContainedWithin.ToList()[0].Id);
            
            Assert.AreEqual("Canada", places[1].FullName);
            Assert.AreEqual("3376992a082d67c7", places[1].Id);
            Assert.AreEqual(TwitterPlaceType.Country, places[1].PlaceType);

            Assert.AreEqual("Ontario, Canada", places[2].FullName);
            Assert.AreEqual(TwitterPlaceType.Admin, places[2].PlaceType);

            Assert.AreEqual("Québec, Canada", places[3].FullName);
            Assert.AreEqual(TwitterPlaceType.Admin, places[3].PlaceType);
        }
コード例 #3
0
 public void Can_tweet_with_protected_resource_info()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     service.AuthenticateWith(_accessToken, _accessTokenSecret);
     var status = service.SendTweet(new SendTweetOptions { Status = DateTime.Now.Ticks.ToString() });
     Assert.IsNotNull(status);
 }
コード例 #4
0
        public void Can_get_media_links_from_entities()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var tweet = service.GetTweet(128818112387756032);
            Assert.IsNotNull(tweet.Entities);
            Assert.AreEqual(1, tweet.Entities.Media.Count);

            var media = tweet.Entities.Media[0];
            Assert.AreEqual("http://p.twimg.com/AcmnZAXCMAEaDD1.jpg", media.MediaUrl);
            Assert.AreEqual("https://p.twimg.com/AcmnZAXCMAEaDD1.jpg", media.MediaUrlHttps);
            Assert.AreEqual("http://twitter.com/sarah_hatton/status/128818112387756032/photo/1", media.ExpandedUrl);
            Assert.AreEqual("pic.twitter.com/xCdS2Emt", media.DisplayUrl);
            Assert.AreEqual(TwitterMediaType.Photo, media.MediaType);
            Assert.AreEqual(69, media.Indices[0]);
            Assert.AreEqual(89, media.Indices[1]);
            Assert.AreEqual("128818112391950337", media.IdAsString);
            Assert.AreEqual(128818112391950337, media.Id);

            // Sizes
            Assert.AreEqual(4, media.Sizes.Count());
            Assert.AreEqual("fit", media.Sizes.Large.Resize);
            Assert.AreEqual(597, media.Sizes.Large.Height);
            Assert.AreEqual(800, media.Sizes.Large.Width);
        }
コード例 #5
0
        public void Can_support_secure_urls_in_entitities()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var tweet = service.GetTweet(131501393033961472);
            Console.WriteLine(tweet.RawSource);
        }
コード例 #6
0
        public void Can_get_basic_place()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            // Presidio
            var place = service.GetPlace("df51dec6f4ee2b2c");
            Assert.IsNotNull(place);
            Assert.AreEqual("df51dec6f4ee2b2c", place.Id);
            Assert.AreEqual("Presidio", place.Name);
            Assert.AreEqual("United States", place.Country);
            Assert.AreEqual("US", place.CountryCode);
            Assert.AreEqual("Presidio, San Francisco", place.FullName);
        }
コード例 #7
0
        public void Can_get_direct_messages()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);
            var dms = service.ListDirectMessagesReceived();

            Assert.IsNotNull(dms);
            Assert.IsTrue(dms.Count() <= 20);

            Assert.IsNotNull(service.Response);
            AssertResultWas(service, HttpStatusCode.OK);

            foreach (var tweet in dms)
            {
                Assert.IsNotNull(tweet.RawSource);
                Assert.AreNotEqual(default(DateTime), tweet.CreatedDate);

                Console.WriteLine("{0} said '{1}'", tweet.SenderScreenName, tweet.Text);
            }

            AssertRateLimitStatus(service);
        }
コード例 #8
0
        public void Can_make_protected_resource_request_with_access_token()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            var request = service.GetRequestToken();

            AssertResultWas(service, HttpStatusCode.OK);
            Assert.NotNull(request);

            var uri = service.GetAuthorizationUri(request);
            Process.Start(uri.ToString());

            Console.WriteLine("Press the any key when you have confirmation of your code transmission.");
            var verifier = "1234567"; // <-- Debugger breakpoint and edit with the actual verifier

            var access = service.GetAccessToken(request, verifier);
            AssertResultWas(service, HttpStatusCode.OK);
            Assert.IsNotNull(access);

            service.AuthenticateWith(access.Token, access.TokenSecret);
            var mentions = service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions());
            Assert.IsNotNull(mentions);
            Assert.AreEqual(20, mentions.Count());
        }
コード例 #9
0
        public void Can_update_account_settings()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var original = service.GetAccountSettings();
            var state = !original.SleepTime.Enabled.Value;

            Trace.WriteLine("Sleep state was " + original.SleepTime.Enabled);
            
            var updated = service.UpdateAccountSettings(state);
            Assert.AreEqual(state, updated.SleepTime.Enabled);

            Trace.WriteLine("Sleep state is now " + updated.SleepTime.Enabled);

            updated = service.UpdateAccountSettings(!state);
            Assert.AreEqual(!state, updated.SleepTime.Enabled);

            Trace.WriteLine("Sleep state is now " + updated.SleepTime.Enabled);
        }
コード例 #10
0
        public static void AdvancedSearch(AdvancedSearchParam criterion, ref ObservableCollection<TwitterStatus> tweets)
        {
            tweets.Clear();
            //TwitterResult response;
            //if (criterion.Distance != 0 && criterion.GeoLocation != null)
            //    response = FluentTwitter.CreateRequest()
            //        .Search().Query().ContainingHashTag(criterion.Tag)
            //        .Containing(criterion.AnyWords).NotContaining(criterion.WithoutWords)
            //        .InLanguage(criterion.Language).Within(criterion.Distance).Of(criterion.GeoLocation)
            //        .AsJson().Request();
            //else
            //    response = FluentTwitter.CreateRequest()
            //        .Search().Query().ContainingHashTag(criterion.Tag)
            //        .AddNotContainingWords(criterion.WithoutWords).Containing(criterion.AnyWords)
            //        .InLanguage(criterion.Language)
            //        .AsJson().Request();

            var service = new TwitterService();
            service.AuthenticateWith(Settings.Default.ConsumerKey,
                            Settings.Default.ConsumerSecret,
                            Model.OAuthHandler.Token,
                            Model.OAuthHandler.TokenSecret);
            TwitterSearchResult results = service.SearchForTweets(criterion.ToString(), 1, 40);
            if (results == null)
                return;

            //ValidateResponse(response);
            //TwitterSearchResult results = response.AsSearchResult();

            foreach (TwitterStatus status in results.Statuses)
            {
                tweets.Add(status);
            }
        }
コード例 #11
0
        public void Can_get_entities_on_direct_messages()
        {
            var service = new TwitterService { IncludeEntities = true };            
            service.AuthenticateWith(_consumerKey, _consumerSecret, _accessToken, _accessTokenSecret);
            
            var tweets = service.ListDirectMessagesSent(new ListDirectMessagesSentOptions());
            if(!tweets.Any())
            {
                Assert.Ignore("No direct messages available to verify entities");
            }

            Console.WriteLine(service.Response.Response);

            foreach (var tweet in tweets)
            {
                Assert.IsNotNull(tweet.Entities);
                var coalesced = tweet.Entities.Coalesce();
                var text = tweet.Text;

                Assert.IsNotNull(tweet.TextAsHtml);
                Console.WriteLine("Tweet: " + text);
                Console.WriteLine("HTML: " + tweet.TextAsHtml);
                foreach(var entity in coalesced)
                {
                    switch(entity.EntityType)
                    {
                        case TwitterEntityType.HashTag:
                            var hashtag = ((TwitterHashTag) entity).Text;
                            Console.WriteLine(hashtag);
                            var hashtagText = text.Substring(entity.StartIndex, entity.EndIndex - entity.StartIndex);
                            Assert.AreEqual("#" + hashtag, hashtagText);
                            break;
                        case TwitterEntityType.Mention:
                            var mention = ((TwitterMention) entity).ScreenName;
                            Console.WriteLine(mention);
                            var mentionText = text.Substring(entity.StartIndex, entity.EndIndex - entity.StartIndex);
                            Assert.AreEqual("@" + mention, mentionText);
                            break;
                        case TwitterEntityType.Url:
                            var url = ((TwitterUrl) entity).Value;
                            Console.WriteLine(url);
                            var urlText = text.Substring(entity.StartIndex, entity.EndIndex - entity.StartIndex);
                            Assert.AreEqual(url, urlText);
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                Console.WriteLine();
            }
        }
コード例 #12
0
        public override TaskStatus Run()
        {
            Info("Sending tweets...");

            bool success           = true;
            bool atLeastOneSucceed = false;

            var files = SelectFiles();

            if (files.Length > 0)
            {
                TwitterService service;
                try
                {
                    service = new TwitterService();
                    service.AuthenticateWith(ConsumerKey, ConsumerSecret, AccessToken, AccessTokenSecret);
                    Info("Authentication succeeded.");
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    ErrorFormat("Authentication failed.", e);
                    return(new TaskStatus(Status.Error, false));
                }

                foreach (FileInf file in files)
                {
                    try
                    {
                        var xdoc = XDocument.Load(file.Path);
                        foreach (XElement xTweet in xdoc.XPathSelectElements("Tweets/Tweet"))
                        {
                            var status = xTweet.Value;
                            var tweet  = service.SendTweet(new SendTweetOptions {
                                Status = status
                            });
                            InfoFormat("Tweet '{0}' sent. id: {1}", status, tweet.Id);
                        }

                        if (!atLeastOneSucceed)
                        {
                            atLeastOneSucceed = true;
                        }
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        ErrorFormat("An error occured while sending the tweets of the file {0}.", e, file.Path);
                        success = false;
                    }
                }
            }

            var tstatus = Status.Success;

            if (!success && atLeastOneSucceed)
            {
                tstatus = Status.Warning;
            }
            else if (!success)
            {
                tstatus = Status.Error;
            }

            Info("Task finished.");
            return(new TaskStatus(tstatus, false));
        }
コード例 #13
0
        public void Can_search_geo_by_ip()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var places = service.GeoSearch(new GeoSearchOptions { Ip = "24.246.1.165" }).ToList();
            Assert.IsNotEmpty(places);

            places = places.OrderBy(p => p.Id).ToList();
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
        }
コード例 #14
0
 public void Can_send_direct_message()
 {
     var service = new TwitterService { IncludeEntities = true };
     service.AuthenticateWith(_consumerKey, _consumerSecret, _accessToken, _accessTokenSecret);
     var response = service.SendDirectMessage(_hero, "http://tweetsharp.com @dimebrain #thisisatest " + DateTime.Now.Ticks);
     
     AssertResultWas(service, HttpStatusCode.OK);
     Assert.IsNotNull(response);
     Assert.IsFalse(response.Id == 0);
 }
コード例 #15
0
        public void Can_make_oauth_echo_request()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var response = service.GetEchoRequest("http://api.twitpic.com/2/users/show.json?username=danielcrenna");
            Assert.IsNotNull(response);
            AssertResultWas(service, HttpStatusCode.OK);
        }
コード例 #16
0
ファイル: MainPage.xaml.cs プロジェクト: nyxtom/tweetsharp
        private void ServiceExample()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken.Token, _accessToken.TokenSecret);
            
            //service.ListTweetsOnPublicTimeline(
            //    (statuses, response) => ProcessIncomingTweets(response, statuses, Dispatcher)
            //    );

            service.ListFollowers(-1,
                (list, response) =>
                    {
                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            foreach(var follower in list)
                            {
                                Console.WriteLine(follower.ScreenName);
                            }
                        }
                    }
                );

            //service.SendTweet(DateTime.Now.Ticks.ToString(),
            //                  (status, response) =>
            //                      {
            //                          if (response.StatusCode == HttpStatusCode.OK)
            //                          {
            //                              var tweet = new Tweet(status);
            //                              dispatcher.BeginInvoke(() => tweets.Items.Add(tweet));
            //                          }
            //                      });
        }
コード例 #17
0
 private void SetupTwitter()
 {
     twitter = new TwitterService("hkqgdQV3Myye16fqVh5zKj75e", "3CmduRd1NQHJlWsBgYW0a2lrBfdV6h7RHFZHUe3zpIpGyFHAYN");
     twitter.AuthenticateWith("1076539766194216961-kczAJ2VkSHBqxPiqiQXu8o4pERimBc", "lbrTQdoIzXvGsELDrCmidt7Zq4XdFY7RFCDMBsga3exDU");
 }
コード例 #18
0
        public void Can_search_geo_by_ip()
        {
					//This test is currently failing. No matter what IP is provided, no result is returned
					//as Twitter says it has no location associated. Still trying to figure out if this
					//is a Twitter problem, data problem, or problem on our end.
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

						var result = service.GeoSearch(new GeoSearchOptions { Ip = "24.246.1.165" });
						Assert.IsNotNull(result);
						var places = result.ToList();
            Assert.IsNotEmpty(places);

            places = places.OrderBy(p => p.Id).ToList();
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
        }
コード例 #19
0
ファイル: LoginController.cs プロジェクト: UpVotes/UpVotes
        public ActionResult TwitterCallback(string oauth_token, string oauth_verifier, string state)
        {
            var requesttoken = new OAuthRequestToken {
                Token = oauth_token
            };
            string key    = ConfigurationManager.AppSettings["TwitterKey"].ToString();
            string secret = ConfigurationManager.AppSettings["TwitterSecret"].ToString();

            string[] myArray = state.Split('-');
            try
            {
                if (oauth_token != null)
                {
                    TwitterService   service     = new TwitterService(key, secret);
                    OAuthAccessToken accesstoken = service.GetAccessToken(requesttoken, oauth_verifier);
                    service.AuthenticateWith(accesstoken.Token, accesstoken.TokenSecret);
                    VerifyCredentialsOptions option = new VerifyCredentialsOptions();
                    TwitterUser user = service.VerifyCredentials(option);
                    TwitterLinkedInLoginModel obj = new TwitterLinkedInLoginModel();
                    if (user != null)
                    {
                        string[] name = user.Name.Split(' ');
                        if (name.Length > 1)
                        {
                            obj.firstName = name[0].ToString();
                            obj.lastName  = name[1].ToString();
                        }
                        else
                        {
                            obj.firstName = name[0].ToString();
                            obj.lastName  = "";
                        }

                        obj.id               = user.Id.ToString();
                        obj.pictureUrl       = user.ProfileImageUrlHttps;
                        obj.publicProfileUrl = "https://twitter.com/" + user.ScreenName;
                        obj.userType         = 3;


                        UserEntity userObj = new Business.UserService().AddOrUpdateUser(obj);
                        Session["UserObj"] = userObj;
                        Session["UserID"]  = userObj.UserID;
                        string message = string.Empty;
                        if (myArray[0] != "0")
                        {
                            if (myArray[1] == "C")
                            {
                                message = new Business.CompanyService().VoteForCompany(Convert.ToInt32(myArray[0]), userObj.UserID);
                                if (CacheHandler.Exists("TopVoteCompaniesList"))
                                {
                                    CacheHandler.Clear("TopVoteCompaniesList");
                                }
                                string compname = "";
                                if (!string.IsNullOrEmpty(Session["CompanyName"].ToString()))
                                {
                                    compname = Session["CompanyName"].ToString();
                                }
                                if (CacheHandler.Exists(compname))
                                {
                                    CacheHandler.Clear(compname);
                                }
                            }
                            else if (myArray[1] == "N")
                            {
                                message = new Business.SoftwareService().VoteForSoftware(Convert.ToInt32(myArray[0]), userObj.UserID);
                                string softwarename = "";
                                if (!string.IsNullOrEmpty(Session["SoftwareName"].ToString()))
                                {
                                    softwarename = Session["SoftwareName"].ToString();
                                }
                                if (CacheHandler.Exists(softwarename))
                                {
                                    CacheHandler.Clear(softwarename);
                                }
                            }
                        }
                    }
                }
                if (myArray[1] == "H")
                {
                    return(Redirect(ConfigurationManager.AppSettings["WebBaseURL"].ToString()));
                }
                else if (myArray[1] == "L")
                {
                    return(Redirect(ConfigurationManager.AppSettings["WebBaseURL"].ToString() + Convert.ToString(Session["FocusAreaName"])));
                }
                else if (myArray[1] == "C")
                {
                    return(Redirect(ConfigurationManager.AppSettings["WebBaseURL"].ToString() + "Profile/" + Convert.ToString(Session["CompanyName"])));
                }
                else if (myArray[1] == "U")
                {
                    return(Redirect(ConfigurationManager.AppSettings["WebBaseURL"].ToString() + "company/my-dashboard"));
                }
                else if (myArray[1] == "S")
                {
                    return(Redirect(ConfigurationManager.AppSettings["WebBaseURL"].ToString() + Convert.ToString(Session["SoftwareCategory"])));
                }
                else if (myArray[1] == "N")
                {
                    return(Redirect(ConfigurationManager.AppSettings["WebBaseURL"].ToString() + "Software/" + Convert.ToString(Session["SoftwareName"])));
                }

                return(null);

                // return RedirectToAction("HomePage", "Home");
            }
            catch (Exception ex)
            {
                EmailHelper.SendErrorEmail(ex);
                throw;
            }
        }
コード例 #20
0
ファイル: BlogController.cs プロジェクト: Julio-CT/uceme
        private void PublicarEnRedesSociales(Blog blog, string nombre, string extension)
        {
            //la direccion del nuevo post es:
            var    direccionnueva = System.Configuration.ConfigurationManager.AppSettings["url_actual"] + "/blog/singlepost/?id=" + blog.idBlog;
            string direccioncorta = null;
            Stream stream         = null;
            Stream responseStream;

            // vamos a meter todo lo de las peticiones en un try distinto, por si acaso
            try
            {
                //
                //acortamos la direccion usando goo.gl
                //
                var httpWebRequest =
                    (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url");
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                stream = httpWebRequest.GetRequestStream();
                using (var streamWriter = new StreamWriter(stream))
                {
                    var json = "{\"longUrl\":\"" + direccionnueva + "\"}";

                    streamWriter.Write(json);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                using (var httpResponse = httpWebRequest.GetResponse() as HttpWebResponse)
                {
                    var jsonSerializer = new DataContractJsonSerializer(typeof(RespuestaGoogle));
                    if (httpResponse != null)
                    {
                        responseStream = httpResponse.GetResponseStream();
                        if (responseStream == null)
                        {
                            throw new NoNullAllowedException("jsonResponse is null");
                        }

                        var objResponse  = jsonSerializer.ReadObject(stream: responseStream);
                        var jsonResponse = objResponse as RespuestaGoogle;
                        if (jsonResponse == null)
                        {
                            throw new NoNullAllowedException("jsonResponse is null");
                        }

                        direccioncorta = jsonResponse.Id;
                    }
                }

                //
                //publicar en tw
                //
                var tweet = string.Format("{0} {1}", blog.titulo, direccioncorta);

                //nos basamos en el las librerias de TwitterSharp de nuget
                var service = new TwitterService(System.Configuration.ConfigurationManager.AppSettings["ConsumerKey"],
                                                 System.Configuration.ConfigurationManager.AppSettings["ConsumerSecret"]);
                service.AuthenticateWith(System.Configuration.ConfigurationManager.AppSettings["AccessToken"],
                                         System.Configuration.ConfigurationManager.AppSettings["AccessTokenSecret"]);
                service.SendTweet(new SendTweetOptions {
                    Status = tweet
                });

                //
                //publicar en fb
                //
                var direccionfoto = System.Configuration.ConfigurationManager.AppSettings["url_actual"] +
                                    "/uploads/fotos/" +
                                    nombre + extension;

                httpWebRequest =
                    (HttpWebRequest)
                    WebRequest.Create("https://graph.facebook.com/" +
                                      System.Configuration.ConfigurationManager.AppSettings["AppId"] + "/feed");

                var url = "https://graph.facebook.com/" + System.Configuration.ConfigurationManager.AppSettings["AppId"] +
                          "/feed?access_token=" + System.Configuration.ConfigurationManager.AppSettings["Token"];

                var parameters = "link=" + direccioncorta + "&picture=" + direccionfoto + "&description=\"" +
                                 blog.titulo + "\"";

                // es un POST con URLENCODED...asi que es distinto
                var webRequest = WebRequest.Create(url);
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.Method      = "POST";

                var bytes = System.Text.Encoding.ASCII.GetBytes(parameters);
                webRequest.ContentLength = bytes.Length;

                var os = webRequest.GetRequestStream();

                os.Write(bytes, 0, bytes.Length);
                os.Close();

                var webResponse = webRequest.GetResponse();
                responseStream = webResponse.GetResponseStream();
                if (responseStream != null)
                {
                    using (var sr = new StreamReader(responseStream))
                    {
                        var postId = sr.ReadToEnd();
                    }
                }
            }
            catch (WebException ex)
            {
                // pillamos la excepcion con todos los detalles
                responseStream = ex.Response.GetResponseStream();
                if (responseStream != null)
                {
                    string errorMessage;
                    using (var errorStream = new StreamReader(responseStream))
                    {
                        errorMessage = errorStream.ReadToEnd();
                    }
                    ModelState.AddModelError("",
                                             Utilidades.ErrorManager.ErrorCodeToString(Utilidades.ErrorCodes.ErrorPublishingToSocialNetwork) +
                                             " " + ex.Message + "" + errorMessage);
                }
            }
            finally
            {
                stream?.Dispose();
            }
        }
コード例 #21
0
        public ActionResult atom_result(string Mention, string PDAM, string PJS, string PJU, string Disdik, string Diskominfo, string Algorithm)
        {
            /* Variabel Global Untuk Search*/
            mention_search    = string.Copy(Mention);
            PDAM_search       = string.Copy(PDAM);
            PJS_search        = string.Copy(PJS);
            PJU_search        = string.Copy(PJU);
            Disdik_search     = string.Copy(Disdik);
            Diskominfo_search = string.Copy(Diskominfo);

            /*Local Variable*/
            string[] tes = new string[5];
            tes[0] = PDAM_search.ToLower();
            tes[1] = PJS_search.ToLower();
            tes[2] = PJU_search.ToLower();
            tes[3] = Disdik_search.ToLower();
            tes[4] = Diskominfo_search.ToLower();
            List <string[]> pemkot = new List <string[]>();
            List <string>   menti  = mention_search.Split(';').ToList <string>();

            /*Use wether BM or KMB Algorithm*/
            if (Algorithm.Equals("BM"))
            {
                use_BM = true;
            }
            else
            {
                use_BM = false;
            }

            //TwitterService
            var service = new TwitterService("5q4cQb8Q9YyOl35vPRZLx8Jjq", "UmFtUuVDIsrOrLI3g4qs8HqYGWjIQ3O4ghfhAu6Sb5Y9QkN2lx");

            //Authenticate
            service.AuthenticateWith("178535721-rRphja9pNDIDK3p1JOx55Joly19vgzRTFBivuNmB", "XU4EFfVN4tlwbGu75POv4FurI571cznMIw3IBPrqIgWSG");

            List <TwitterStatus> tweet = new List <TwitterStatus>();

            //Search by key
            if (menti.Count != 0)
            {
                foreach (string ment in menti)
                {
                    TwitterSearchResult searchRes = service.Search(new SearchOptions {
                        Q = ment.ToLower(), Count = 100,
                    });
                    var tweets = searchRes.Statuses;

                    if (tweets != null)
                    {
                        foreach (TwitterStatus t in tweets)
                        {
                            tweet.Add(t);
                        }
                    }
                }
            }



            /*Beginning of iti*/

            //Seperate semicolom (;)
            for (int i = 0; i < 5; i++)
            {
                pemkot.Add(tes[i].Split(';'));
            }

            /**============FILTER===========**/
            stat = new List <TwitterStatus> [6];
            for (int i = 0; i < 6; i++)
            {
                stat[i] = new List <TwitterStatus>();
            }
            KMP kmp = new KMP();
            BM  bm  = new BM();

            for (int j = 0; j < 5; j++)
            {
                for (int i = 0; i < pemkot[j].Length; i++)
                {
                    string x = pemkot[j][i];
                    List <TwitterStatus> tweetx = new List <TwitterStatus>(tweet);
                    foreach (TwitterStatus t in tweetx)
                    {
                        if (use_BM == false)
                        {
                            //KMP Algorithm
                            if (kmp.KMPSearch(t.Text, x))
                            {
                                stat[j].Add(t);
                                tweet.Remove(t);
                            }
                        }
                        else
                        {
                            //BM ALgorithm
                            if (bm.BMSearch(t.Text, x))
                            {
                                stat[j].Add(t);
                                tweet.Remove(t);
                            }
                        }
                    }
                }
            }



            stat[5] = new List <TwitterStatus>(tweet);
            tweet.Clear();

            LocationAnalyzer la = new LocationAnalyzer();

            List <string>[] location = new List <string> [6];
            for (int o = 0; o < 6; o++)
            {
                location[o] = new List <string>();
                foreach (TwitterStatus tx in stat[0])
                {
                    string temp = la.getTempat(tx.Text);
                    if (temp != "")
                    {
                        location[o].Add(temp);
                    }
                }
            }

            ViewBag.PDAM       = stat[0];
            ViewBag.PJU        = stat[1];
            ViewBag.Dissos     = stat[2];
            ViewBag.Disdik     = stat[3];
            ViewBag.Diskominfo = stat[4];
            ViewBag.Other      = stat[5];

            ViewBag.PDAMloc       = location[0];
            ViewBag.PJUloc        = location[1];
            ViewBag.Dissosloc     = location[2];
            ViewBag.Disdikloc     = location[3];
            ViewBag.Diskominfloc  = location[4];
            ViewBag.Otherloc      = location[5];
            ViewBag.OtherlocCount = location[5].Count;

            ViewBag.PDAM_Count       = stat[0].Count;
            ViewBag.PJU_Count        = stat[1].Count;
            ViewBag.Dissos_Count     = stat[2].Count;
            ViewBag.Disdik_Count     = stat[3].Count;
            ViewBag.Diskominfo_Count = stat[4].Count;
            ViewBag.Other_Count      = stat[5].Count;

            /*END of ITI*/
            return(View());
        }
コード例 #22
0
 public void Can_verify_credentials()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     service.AuthenticateWith(_accessToken, _accessTokenSecret);
     var user = service.VerifyCredentials();
     Assert.IsNotNull(user);
 }
コード例 #23
0
 private static void initTwitter()
 {
     service = new TwitterService("Zu9eMYImenEPW3WA7Z6zs6eAL", "it8ezCqWXD8TjC8Sbc8PfoJHvTdtdhn26DuQcnufIbzPDBIHgM");
     service.AuthenticateWith("102982151-hGLzg7DRFOpo4QtujwqfLBG9kjyLnj0rZAWBwzjI", "D8qKQmmVCyrvWG24mBSSzIHr3ZojFrgdvbMTVYTtnwTyT");
 }
コード例 #24
0
        public void Can_search_geo_by_lat_long()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var places = service.GeoSearch(new GeoSearchOptions { Lat = 45.42153, Long = -75.697193}).ToList();
            Assert.IsNotEmpty(places);

            places = places.OrderBy(p => p.Id).ToList();
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
        }
コード例 #25
0
 public void Can_send_direct_message()
 {
     var service = new TwitterService { IncludeEntities = true };
     service.AuthenticateWith(_consumerKey, _consumerSecret, _accessToken, _accessTokenSecret);
     var response = service.SendDirectMessage(new SendDirectMessageOptions
     {
         ScreenName = _hero,
         Text = "Test a tweetsharp dm " + DateTime.Now.Ticks
     });
     
     AssertResultWas(service, HttpStatusCode.OK);
     Assert.IsNotNull(response);
     Assert.IsFalse(response.Id == 0);
 }
コード例 #26
0
        public void Can_create_and_destroy_saved_search()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            // Twitter 403's on duplicate saved search requests, so delete if found
            var searches = service.ListSavedSearches(new ListSavedSearchesOptions());
            Assert.IsNotNull(searches);

            var existing = searches.SingleOrDefault(s => s.Query.Equals("tweetsharp"));
            if(existing != null)
            {
                var deleted = service.DeleteSavedSearch(new DeleteSavedSearchOptions { Id = existing.Id });
                Assert.IsNotNull(deleted);
                Assert.IsNotNullOrEmpty(deleted.Query);
                Assert.AreEqual(deleted.Query, existing.Query);
            }

            var search = service.CreateSavedSearch(new CreateSavedSearchOptions { Query = "tweetsharp" });
            Assert.IsNotNull(search);
            Assert.AreEqual("tweetsharp", search.Query);
        }
コード例 #27
0
        public void Can_get_geo_coordinates_from_specific_tweet()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            /*
             "geo": {
                    "type": "Point",
                    "coordinates": [
                        46.01364037,
                        -81.40501187
                    ]
                }, 
             */

            var last = service.GetTweet(new GetTweetOptions { Id = 133314374797492224 });
            Assert.IsNotNull(last.Place);
            Assert.IsNotNull(last.Location);
            Assert.AreEqual("Point", last.Location.Type);
            Assert.AreEqual(46.01364037, last.Location.Coordinates.Latitude);
            Assert.AreEqual(-81.40501187, last.Location.Coordinates.Longitude);
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: silasary/IntFicBot
        private static void Main(string[] args)
        {
            var appInfo = new
            {
                CLIENT_ID     = Environment.GetEnvironmentVariable("CLIENT_ID"),
                CLIENT_SECRET = Environment.GetEnvironmentVariable("CLIENT_SECRET")
            };

            if (File.Exists("AppAuth.json"))
            {
                appInfo = JsonConvert.DeserializeAnonymousType(File.ReadAllText("AppAuth.json"), appInfo);
            }

            if (appInfo.CLIENT_ID == null || appInfo.CLIENT_SECRET == null)
            {
                string id = appInfo.CLIENT_ID;
                if (appInfo.CLIENT_ID == null)
                {
                    Console.Write("AppID: ");
                    id = Console.ReadLine();
                }

                string secret = appInfo.CLIENT_SECRET;
                if (appInfo.CLIENT_SECRET == null)
                {
                    Console.Write("Secret: ");
                    secret = Console.ReadLine();
                }

                appInfo = new
                {
                    CLIENT_ID     = id,
                    CLIENT_SECRET = secret
                };
                File.WriteAllText("AppAuth.json", JsonConvert.SerializeObject(appInfo));
            }


            service = new TwitterService(appInfo.CLIENT_ID, appInfo.CLIENT_SECRET);
            access  = null;
            if (File.Exists("token.json"))
            {
                access = service.Deserialize <OAuthAccessToken>(File.ReadAllText("token.json"));
            }

            if (access == null)
            {
                OAuthRequestToken requestToken = service.GetRequestToken();
                Uri uri = service.GetAuthorizationUri(requestToken);
                Console.WriteLine(uri.ToString());
                var verifier = Console.ReadLine();
                access = service.GetAccessToken(requestToken, verifier);
                var tokenstr = service.Serializer.Serialize(access, typeof(OAuthAccessToken));
                File.WriteAllText("token.json", tokenstr);
            }

            service.AuthenticateWith(access.Token, access.TokenSecret);

            Console.WriteLine($"Authenticated as {access.ScreenName}");

            foreach (string gamelink in RandomGames())
            {
                string source;
                try
                {
                    var link = gamelink.Replace("about://", "");
                    source = GetSourceFromGamePage(link);
                    if (source == null)
                    {
                        continue;
                    }

                    Console.WriteLine();
                    Console.WriteLine(source);
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                try
                {
                    switch (Path.GetExtension(source))
                    {
                    case ".txt":
                    case ".ni":

                        ReadSource(source);
                        break;

                    case ".html":
                        //todo: Deal with HTML source files.
                        ReadSource(source.Replace(".html", ".txt"));
                        break;

                    case ".zip":
                    case ".sit":
                        break;

                    default:
                        // Try anyway?
                        ReadSource(source);
                        break;
                    }
                }
                catch (WebException c)
                {
                    // 404 or some such error. Go to the Next story.
                    continue;
                }
            }
        }
コード例 #29
0
				private TwitterService GetAuthenticatedService(JsonSerializer serializer)
				{
					var service = new TwitterService(_consumerKey, _consumerSecret);
					if (serializer != null)
					{
						service.Serializer = serializer;
						service.Deserializer = serializer;
					}

					service.TraceEnabled = true;
					service.AuthenticateWith(_accessToken, _accessTokenSecret);
					return service;
				}
コード例 #30
0
        public void Can_get_parameterized_followers_of_lists()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var result = service.ListUserProfilesFor(new [] { "danielcrenna"}, new[] {12345});
            Assert.AreEqual(2, result.Count());
        }
コード例 #31
0
        public void Can_get_friends_or_followers_with_next_cursor()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var followers = service.ListFollowers(new ListFollowersOptions { ScreenName = _hero });
            Assert.IsNotNull(followers);
            Assert.IsNotNull(followers.NextCursor);
            Assert.IsNotNull(followers.PreviousCursor);
        }
コード例 #32
0
        public void Can_get_updated_user_properties()
        {
            //{"is_translator":false,
            //"geo_enabled":false,
            //"profile_background_color":"1A1B1F",
            //"protected":false,
            //"profile_background_tile":false,
            //"created_at":"Fri Dec 14 18:48:52 +0000 2007",
            //"name":"Daniel Crenna",
            //"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme9\/bg.gif",
            //"profile_sidebar_fill_color":"252429",
            //"listed_count":102,
            //"notifications":false,
            //"utc_offset":-18000,
            //"friends_count":277,
            //"description":"Code soloist.",
            //"following":false,
            //"verified":false,
            //"profile_sidebar_border_color":"181A1E",
            //"followers_count":1193,
            //"profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/700778992\/684676c4ec78fa88144b5256dd880986_normal.png",
            //"default_profile":false,
            //"contributors_enabled":false,
            //"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/700778992\/684676c4ec78fa88144b5256dd880986_normal.png",
            //"status":{"possibly_sensitive":false,"place":null,"retweet_count":0,"in_reply_to_screen_name":null,"created_at":"Sun Nov 06 14:23:43 +0000 2011","retweeted":false,"in_reply_to_status_id_str":null,"in_reply_to_user_id_str":null,"contributors":null,"id_str":"133187813599481856","in_reply_to_user_id":null,"in_reply_to_status_id":null,"source":"\u003Ca href=\"http:\/\/twitter.com\/tweetbutton\" rel=\"nofollow\"\u003ETweet Button\u003C\/a\u003E","geo":null,"favorited":false,"id":133187813599481856,"entities":{"urls":[{"display_url":"binpress.com\/blog\/2011\/08\/2\u2026","indices":[53,73],"url":"http:\/\/t.co\/KTGrKmeK","expanded_url":"http:\/\/www.binpress.com\/blog\/2011\/08\/25\/why-isnt-it-free-commercial-open-source\/"}],"user_mentions":[{"name":"Binpress","indices":[78,87],"screen_name":"Binpress","id_str":"204787796","id":204787796}],"hashtags":[]},"coordinates":null,"truncated":false,"text":"Why isn't it free - commercial open-source revisited http:\/\/t.co\/KTGrKmeK via @binpress"},"profile_use_background_image":true,"favourites_count":151,"location":"Ottawa, ON, Canada","id_str":"11173402","default_profile_image":false,"show_all_inline_media":true,"profile_text_color":"666666","screen_name":"danielcrenna","statuses_count":4669,"profile_background_image_url":"http:\/\/a1.twimg.com\/images\/themes\/theme9\/bg.gif","url":"http:\/\/danielcrenna.com","time_zone":"Eastern Time (US & Canada)","profile_link_color":"2FC2EF","id":11173402,
            //"follow_request_sent":false,
            //"lang":"en"}
            
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var user = service.GetUserProfile();
            Assert.AreEqual(true, user.ShowAllInlineMedia);
            Assert.AreEqual(false, user.FollowRequestSent);
            Assert.AreEqual(false, user.IsTranslator);
            Assert.AreEqual(false, user.ContributorsEnabled);
            Assert.IsTrue(user.ProfileBackgroundImageUrlHttps.StartsWith("https://"));
            Assert.IsTrue(user.ProfileImageUrlHttps.StartsWith("https://"));
            Assert.AreEqual(false, user.IsDefaultProfile);
        }
コード例 #33
0
        public void Can_delete_direct_message()
        {
            var service = new TwitterService { IncludeEntities = true };
            service.AuthenticateWith(_consumerKey, _consumerSecret, _accessToken, _accessTokenSecret);
            var created = service.SendDirectMessage(new SendDirectMessageOptions
            {
                ScreenName = _hero,
                Text = "http://tweetsharp.com @dimebrain #thisisatest " + DateTime.Now.Ticks
            });
            AssertResultWas(service, HttpStatusCode.OK);
            Assert.IsNotNull(created);
            Assert.IsFalse(created.Id == 0);

            var deleted = service.DeleteDirectMessage(new DeleteDirectMessageOptions { Id = created.Id});
            Assert.IsNotNull(deleted);
            Assert.AreEqual(deleted.Id, created.Id);
        }
コード例 #34
0
        public void Can_return_results_from_account_settings_endpoint()
        {
            //{"protected":false,
            //"geo_enabled":false,
            //"trend_location":[{"countryCode":"CA","name":"Canada","country":"Canada","placeType":{"name":"Country","code":12},"woeid":23424775,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424775","parentid":1}],
            //"language":"en",
            //"sleep_time":{"start_time":0,"end_time":12,"enabled":true},
            //"always_use_https":false,
            //"screen_name":"danielcrenna",
            //"show_all_inline_media":false,
            //"time_zone":{"name":"Eastern Time (US & Canada)","utc_offset":-18000,"tzinfo_name":"America\/New_York"},
            //"discoverable_by_email":true}

            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var account = service.GetAccountSettings();
            Console.WriteLine(account.RawSource);

            Assert.AreEqual(false, account.IsProtected);
            Assert.AreEqual(true, account.GeoEnabled);
            Assert.IsNotNull(account.TrendLocations);
            Assert.AreEqual(1, account.TrendLocations.Count());
            Assert.AreEqual("CA", account.TrendLocations.Single().CountryCode);
            Assert.AreEqual("Canada", account.TrendLocations.Single().Name);
            Assert.AreEqual("Canada", account.TrendLocations.Single().Country);
            Assert.AreEqual("en", account.Language);
            Assert.AreEqual("danielcrenna", account.ScreenName);
            Assert.AreEqual(true, account.ShowAllInlineMedia);
            Assert.IsNotNull(account.TimeZone);
            Assert.AreEqual("Eastern Time (US & Canada)", account.TimeZone.Name);
            Assert.AreEqual(-18000, account.TimeZone.UtcOffset);
            Assert.AreEqual("America/New_York", account.TimeZone.InfoName);
            Assert.IsNotNull(account.SleepTime);
            Assert.AreEqual(0, account.SleepTime.StartTime, "start_time");
            Assert.AreEqual(12, account.SleepTime.EndTime, "end_time");
            Assert.AreEqual(true, account.SleepTime.Enabled);
        }
コード例 #35
0
 private TwitterService GetAuthenticatedService()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     service.TraceEnabled = true;
     service.AuthenticateWith(_accessToken, _accessTokenSecret);
     return service;
 }
コード例 #36
0
        public static List <long> getFollowerIDs(int index = 0, string next_cursor = "")
        {
            // JObject result_ids = null;

            /*   public static JObject getFollowerIDs(string next_cursor ,int index=0)
             *           try
             *         {
             *
             *
             *             var oauth_consumer_key = consumer_key;
             *             var oauth_consumer_secret = consumer_seckey;
             *             //Token URL
             *             var oauth_url = "https://api.twitter.com/oauth2/token";
             *             var headerFormat = "Basic {0}";
             *             var authHeader = string.Format(headerFormat,
             *             Convert.ToBase64String(Encoding.UTF8.GetBytes(Uri.EscapeDataString(oauth_consumer_key[index]) + ":" +
             *             Uri.EscapeDataString((oauth_consumer_secret[index])))
             *             ));
             *
             *             var postBody = "grant_type=client_credentials";
             *
             *             ServicePointManager.Expect100Continue = false;
             *             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url);
             *             request.Headers.Add("Authorization", authHeader);
             *             request.Method = "POST";
             *             request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
             *
             *             using (Stream stream = request.GetRequestStream())
             *             {
             *                 byte[] content = ASCIIEncoding.ASCII.GetBytes(postBody);
             *                 stream.Write(content, 0, content.Length);
             *             }
             *
             *             request.Headers.Add("Accept-Encoding", "gzip");
             *             HttpWebResponse response = request.GetResponse() as HttpWebResponse;
             *             Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
             *             JObject result_token;
             *             TwitAuthenticateResponse twitAuthResponse;
             *             using (var reader = new StreamReader(responseStream))
             *             {
             *                 // JavaScriptSerializer js = new JavaScriptSerializer();
             *                 var objText = reader.ReadToEnd();
             *                 // result_token = JObject.Parse(objText);
             *                 twitAuthResponse = JsonConvert.DeserializeObject<TwitAuthenticateResponse>(objText);
             *             }
             *
             *             //Get the follower ids
             *
             *             var url = "https://api.twitter.com/1.1/followers/ids.json?cursor=" + next_cursor + "&screen_name=vacationsabroad&skip_status=true&include_user_entities=false";
             *             //var url = "https://api.twitter.com/1.1/direct_messages/new.json?text=hello%2C%20tworld.%20welcome%20to%201.1.&screen_name=andrew_lidev";
             *
             *             HttpWebRequest timeLineRequest = (HttpWebRequest)WebRequest.Create(url);
             *             var timelineHeaderFormat = "{0} {1}";
             *             timeLineRequest.Headers.Add("Authorization", string.Format(timelineHeaderFormat, twitAuthResponse.token_type, twitAuthResponse.access_token));
             *             timeLineRequest.Method = "GET";
             *             WebResponse timeLineResponse = timeLineRequest.GetResponse();
             *             var timeLineJson = string.Empty;
             *
             *
             *
             *             using (timeLineResponse)
             *             {
             *                 using (var reader = new StreamReader(timeLineResponse.GetResponseStream()))
             *                 {
             *                     timeLineJson = reader.ReadToEnd();
             *                     CommonProvider.WriteErrorLog(timeLineJson);
             *                     result_ids = JObject.Parse(timeLineJson);
             *
             *                 }
             *             }
             *         }
             *         catch(Exception ex)
             *         {
             *             CommonProvider.WriteErrorLog(index +"===>" + ex.Message + " :Source Message" +ex.Source);
             *         }
             *         return result_ids;
             */
            List <long> lstFollowers = new List <long>();

            try
            {
                var service = new TwitterService(consumer_key[index], consumer_seckey[index]);
                service.AuthenticateWith(access_token[index], access_sectoken[index]);

                long t_userid = userids[index];

                try
                {
                    TwitterUser tuSelf = service.GetUserProfile(
                        new GetUserProfileOptions()
                    {
                        IncludeEntities = false, SkipStatus = false
                    });
                    t_userid = tuSelf.Id;
                }catch (Exception ex)
                {
                    WriteErrorLog(String.Format("{0}==>Used instead of userid. Get Profile Error;{1} source:{2} stack:{3}", index, ex.Message, ex.Source, ex.StackTrace));
                }

                //Console.WriteLine(String.Format("{0} {1} {2}", tuSelf.Id, tuSelf.ScreenName, tuSelf.FollowersCount));
                // return;
                // var options = new ListFollowersOptions { ScreenName = tuSelf.ScreenName };

                /*        ListFollowersOptions options = new ListFollowersOptions();
                 *           //   options.UserId = tuSelf.Id;
                 *              options.ScreenName = tuSelf.ScreenName;
                 *              options.IncludeUserEntities = false;
                 *              options.SkipStatus = true;
                 *              options.Cursor = -1;
                 *
                 *              List<TwitterUser> lstFollowers = new List<TwitterUser>();
                 *            TwitterCursorList<TwitterUser> followers = service.ListFollowers(options);
                 */

                ListFollowerIdsOfOptions options = new ListFollowerIdsOfOptions();
                options.Cursor = -1;
                options.Count  = 3000;
                options.UserId = t_userid;

                // if the API call did not succeed

                while (true)
                {
                    TwitterCursorList <long> followers = service.ListFollowerIdsOf(options);
                    //If the followers exists
                    if (followers == null)
                    {
                        WriteErrorLog(index + "===> there is no followers !! error");
                        break;
                    }
                    else
                    {
                        foreach (long user in followers)
                        {
                            // do something with the user (I'm adding them to a List)
                            lstFollowers.Add(user);
                        }
                    }

                    // if there are more followers
                    if (followers.NextCursor != null &&
                        followers.NextCursor != 0)
                    {
                        // then advance the cursor and load the next page of results
                        options.Cursor = followers.NextCursor;
                        followers      = service.ListFollowerIdsOf(options);
                    }
                    // otherwise, we're done!
                    else
                    {
                        break;
                    }
                }
            }catch (Exception ex)
            {
                WriteErrorLog(String.Format("{0}===>Error: {1} Sourc: {2}", index, ex.Message, ex.Source));
            }

            return(lstFollowers);
        }