protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Autorize);

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button>(Resource.Id.sumbit);

			button.Click += delegate {
				EditText textLogin = FindViewById<EditText> (Resource.Id.login);
				EditText textPass = FindViewById<EditText> (Resource.Id.password);
				string login = textLogin.Text.ToString ();
				string pass = textPass.Text.ToString ();
				// TODO change OAuth keys and tokens and username and password 

				config = new ConfigurationBuilder ();
				config.SetOAuthConsumerKey ("nz2FD8IELdrglLbNMJ1WeMsze");
				config.SetOAuthConsumerSecret ("Q5ZGt7Bc2McY3xdfjks3AU4yw5DKKSv0h3oXCTpjYhV25qwKL0");
				config.SetOAuthAccessToken ("4359603449-6z2CXsqmH4REQayCNgqwq71wM49PjbkSmNIUJil");
				config.SetOAuthAccessTokenSecret ("nAvebHjYLn1JXnO4PwqtmTBhPoet5rhIRUnlKghtmT8Ns");
				config.SetUser (login);
				config.SetPassword (pass);

				factory = new TwitterFactory (config.Build ());
				twitter = factory.Instance;

				GetInfo ();
			};
		}
Пример #2
0
        public override void LoadContent()
        {
            InitializeButtons();
            InitializeGuides();

            _pinTextBox = new TextBox(ScreenManager.Game)
                              {
                                  Posistion = new Vector2(180, 270),
                                  TextHorizontalMargin = 50,
                                  Width = 350,
                                  Height = 70,
                                  MaxLength = 10,
                                  TextColor = Color.RoyalBlue
                              };

            _pinTextBox.Initialize();

            _twitter = ScreenManager.Game.Services.GetService<ITwitter>();

            if (_twitter.IsInitialized)
            {
                Process.Start(_twitter.AuthenticationUri);
            }

            base.LoadContent();
        }
Пример #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Autorize);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.sumbit);

            button.Click += delegate {
                EditText textLogin = FindViewById <EditText> (Resource.Id.login);
                EditText textPass  = FindViewById <EditText> (Resource.Id.password);
                string   login     = textLogin.Text.ToString();
                string   pass      = textPass.Text.ToString();
                // TODO change OAuth keys and tokens and username and password

                config = new ConfigurationBuilder();
                config.SetOAuthConsumerKey("nz2FD8IELdrglLbNMJ1WeMsze");
                config.SetOAuthConsumerSecret("Q5ZGt7Bc2McY3xdfjks3AU4yw5DKKSv0h3oXCTpjYhV25qwKL0");
                config.SetOAuthAccessToken("4359603449-6z2CXsqmH4REQayCNgqwq71wM49PjbkSmNIUJil");
                config.SetOAuthAccessTokenSecret("nAvebHjYLn1JXnO4PwqtmTBhPoet5rhIRUnlKghtmT8Ns");
                config.SetUser(login);
                config.SetPassword(pass);

                factory = new TwitterFactory(config.Build());
                twitter = factory.Instance;

                GetInfo();
            };
        }
Пример #4
0
        public static async Task <OperationResult <bool> > sendTweet(string msg, string token)
        {
            char[] delimiterChars = { ':' };

            string[] words = token.Split(delimiterChars);

            //OAuthToken token2 = new OAuthToken(words[1],words[0]);
            ITwitter twitterClient = twitterProvider.GetApi(words[1], words[0]);

            try
            {
                var res = await twitterClient.TimelineOperations.UpdateStatusAsync(msg);

                return(new OperationResult <bool>()
                {
                    Result = true, Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <bool>()
                {
                    Success = false, Message = e.InnerException.Message
                });
            }
        }
Пример #5
0
        public ActionResult Index()
        {
            ITwitter twitter = BirdFeeder.Create();

            //twitter.Tweet("restlessmedia", "I love smell of demos in the morning. No-one ever said.");

            return(View(twitter.Tweets("restlessmedia", 5)));
        }
Пример #6
0
        public void BeforeScenario()
        {
            var accounts = new[] {"pay_by_phone", "PayByPhone", "PayByPhone_UK"};

            _twitter = MockRepository.GenerateStub<ITwitter>();
            IGetPBPTweetsService getPBPTweetsService = new GetPBPTweetsService(accounts, _twitter);

            _controller = new PBPTweetsController(getPBPTweetsService);
        }
        // GET: /Twitter/UpdateStatus
        public ActionResult UpdateStatus()
        {
            OAuthToken token         = Session["AccessToken"] as OAuthToken;
            ITwitter   twitterClient = twitterProvider.GetApi(token.Value, token.Secret);

            IList <Tweet> tweets = twitterClient.TimelineOperations.GetHomeTimelineAsync().Result;

            return(View(tweets));
        }
Пример #8
0
        public void BeforeScenario()
        {
            var accounts = new[] { "pay_by_phone", "PayByPhone", "PayByPhone_UK" };

            _twitter = MockRepository.GenerateStub <ITwitter>();
            IGetPBPTweetsService getPBPTweetsService = new GetPBPTweetsService(accounts, _twitter);

            _controller = new PBPTweetsController(getPBPTweetsService);
        }
        public ActionResult UpdateStatus(string status)
        {
            OAuthToken token         = Session["AccessToken"] as OAuthToken;
            ITwitter   twitterClient = twitterProvider.GetApi(token.Value, token.Secret);

            twitterClient.UpdateStatusAsync(status).Wait();

            return(View());
        }
Пример #10
0
        protected override void OnStartup(StartupEventArgs e)
        {
            twitter = new TwitterHelper();
            data    = new DataBasedHelper();
            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel();
            MainWindow          window = new MainWindow(mainWindowViewModel);

            base.OnStartup(e);
            window.ShowDialog();
        }
        public void ShowHomeTimeline()
        {
            ITwitter twitterClient = this.TwitterServiceProvider.GetApi(this.OAuthToken.Value, this.OAuthToken.Secret);

            twitterClient.TimelineOperations.GetHomeTimelineAsync(
                r =>
            {
                this.Tweets = r.Response;
            });
        }
Пример #12
0
        private ITwitter twitter; //new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);

        public TwitterService()
        {
            string consumerKey       = ConfigurationManager.AppSettings["TwitterConsumerKey"];    // The application's consumer key
            string consumerSecret    = ConfigurationManager.AppSettings["TwitterConsumerSecret"]; // The application's consumer secret
            string accessToken       = ConfigurationManager.AppSettings["TwitterAccessToken"];
            string accessTokenSecret = ConfigurationManager.AppSettings["TwitterAccessTokenSecret"];

            TwitterServiceProvider serviceProvider = new TwitterServiceProvider(consumerKey, consumerSecret);

            twitter = new TwitterTemplate(consumerKey, consumerSecret, accessToken, accessTokenSecret);
        }
        // GET: /Twitter/Callback
        public ActionResult Callback(string oauth_verifier)
        {
            OAuthToken             requestToken           = Session["RequestToken"] as OAuthToken;
            AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, oauth_verifier);
            OAuthToken             token = twitterProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null).Result;

            Session["AccessToken"] = token;

            ITwitter       twitterClient = twitterProvider.GetApi(token.Value, token.Secret);
            TwitterProfile profile       = twitterClient.UserOperations.GetUserProfileAsync().Result;

            return(View(profile));
        }
Пример #14
0
        public static void AwakeInit()
        {
            twitterGameObject = new GameObject("TwitterGameObject");
            twitterGameObject.AddComponent <TwitterComponent> ();

#if UNITY_IOS && !UNITY_EDITOR
            twitter = new IOSTwitterImpl();
#elif UNITY_ANDROID && !UNITY_EDITOR
            twitter = new AndroidTwitterImpl();
#else
            twitter = new EditorTwitterImpl();
#endif
        }
Пример #15
0
        private static void PerformInitialTimelineLoad(IDocumentStore store, ITwitter ctx, string psScreenName)
        {
            using (IDocumentSession s = store.OpenSession())
            {
                IList<Tweet> tweets = GetUserTimeLine(ctx, psScreenName);

                foreach (var tweet in tweets)
                {
                    Console.WriteLine("{0} - Message -> {1}", tweet.User.ScreenName, tweet.Text);
                    s.Store(tweet);
                }

                s.SaveChanges();
            }
        }
        //Conectar con API de Twitter mediante PIN para obtener token de acceso
        //devuelve true si la conexión se ha realizado correctamente
        public bool obtenerTokenTwitter(ref string resultado, formTwitter form)
        {
            try
            {
                var auth = new SingleUserAuthorizer
                {
                    CredentialStore = new SingleUserInMemoryCredentialStore
                    {
                        ConsumerKey       = form.consumer_key,
                        ConsumerSecret    = form.consumer_secret,
                        AccessToken       = form.access_token,
                        AccessTokenSecret = form.access_token_secret
                    }
                };

                context = new TwitterContext(auth);

                TwitterServiceProvider twitterServiceProvider =
                    new TwitterServiceProvider(form.consumer_key, form.consumer_secret);
                // Autenticación en Twitter usando código PIN
                OAuthToken oauthToken =
                    twitterServiceProvider.OAuthOperations.FetchRequestTokenAsync("oob", null).Result;
                string authenticateUrl =
                    twitterServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                System.Diagnostics.Process.Start(authenticateUrl);

                string pinCode = "";
                InputBox.solicitarTexto("Código PIN",
                                        "Introduzca el código PIN obtenido de Twitter:", ref pinCode);
                // Step 3 - Exchange the Request Token for an Access Token
                string verifier = pinCode; // <-- This is input into your application by your user

                AuthorizedRequestToken requestToken =
                    new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken oauthAccessToken =
                    twitterServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
                twitter   = twitterServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
                resultado = System.DateTime.Now + " " +
                            "Conectado a API de twitter correctamente con PIN";
                return(true);
            }
            catch (Exception error)
            {
                resultado = System.DateTime.Now + " " +
                            "Error al obtener token acceso Twitter: " + error.Message;
                return(false);
            }
        }
Пример #17
0
        public TwitterManager(ITwitter twitter)
        {
            _twitter = twitter;

            using (var fs = new FileStream("TwitterManager.config", FileMode.Open))
            {
                var doc = new XmlDocument();
                doc.Load(fs);
                _developerScreenName = doc["root"]["DeveloperScreenName"].InnerText;
            }

            _screenName = _twitter.GetScreenName().Result;

            // if _screenName == null, throws NullReferenceException
            _validReplyToStr = new[] { $"@{_screenName.ToString()}", $".@{_screenName.ToString()}" };
        }
Пример #18
0
        public AuthModule(ITwitter twitter) : base("/auth")
        {
            Get["/twitter"] = _ =>
            {
                string callback = TwitterCallback;
                if (Request.Query.returnUrl != null)
                {
                    callback += "?returnUrl=" + ((string)Request.Query.returnUrl).UrlEncode();
                }
                return(new RedirectResponse(twitter.GetAuthorizeUri(ConsumerKey, ConsumerSecret, new Uri(callback)).ToString()));
            };

            Get["/twitter_callback"] = _ => this.LoginAndRedirect((Guid)twitter.GetUser(ConsumerKey, ConsumerSecret,
                                                                                        Request.Query.oauth_token,
                                                                                        Request.Query.oauth_verifier).
                                                                  UserGuid, DateTime.Today.AddDays(1), Request.Query.returnUrl as string ?? "/");
        }
Пример #19
0
        private static IList<Tweet> GetUserTimeLine(ITwitter pxTwitterCtx, string psScreenName)
        {
            ulong statusesCount = 1400;
            int i = Convert.ToInt32(statusesCount);

            IList<Tweet> twits = new List<Tweet>();

            while (i > 0)
            {
                // sinceId and maxId
                var task = pxTwitterCtx.TimelineOperations.GetUserTimelineAsync(psScreenName, 200);
                twits.AddRange(task.Result);
                i = i - 200;
            }

            return twits;
        }
        /// <summary>
        /// Login in Twitter (LoginViaTwitterCommand handler)
        /// </summary>
        private async void LoginViaTwitter()
        {
            Analytics.TrackEvent("Twitter login button clicked",
                                 new Dictionary <string, string>
            {
                { "Page", "Login" },
                { "Category", "Clicks" }
            });

            ITwitter twitterService = DependencyService.Get <ITwitter>(DependencyFetchTarget.GlobalInstance);

            twitterService.OnError += error => AuthError("Twitter", error);

            SocialAccount account = await twitterService.Login();

            await Login(account, "Twitter");
        }
Пример #21
0
        public AuthModule(ITwitter twitter)
            : base("/auth")
        {
            Get["/twitter"] = _ =>
                                  {
                                      string callback = TwitterCallback;
                                      if (Request.Query.returnUrl != null)
                                      {
                                          callback += "?returnUrl=" + ((string) Request.Query.returnUrl).UrlEncode();
                                      }
                                      return new RedirectResponse(twitter.GetAuthorizeUri(ConsumerKey, ConsumerSecret, new Uri(callback)).ToString());
                                  };

            Get["/twitter_callback"] = _ => this.LoginAndRedirect((Guid) twitter.GetUser(ConsumerKey, ConsumerSecret,
                                                                                         Request.Query.oauth_token,
                                                                                         Request.Query.oauth_verifier).
                                                                             UserGuid, DateTime.Today.AddDays(1), Request.Query.returnUrl as string ?? "/");
        }
Пример #22
0
        private static void RunRavenEmbedded(ITwitter ctx, string twitterHandle)
        {
            using (var store = new EmbeddableDocumentStore
            {
                DataDirectory = "~/App_Data/Database",
                RunInMemory = true,
                UseEmbeddedHttpServer = true,
            })
            {
                NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(9090);
                store.Initialize();
                store.HttpServer.SystemConfiguration.AllowLocalAccessWithoutAuthorization = true;

                Console.Write("RavenDb Embedded Document Store Initialized Successfully.");

                PerformInitialTimelineLoad(store, ctx, twitterHandle);

                Console.ReadKey();
            }
        }
Пример #23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Assigning controls
            Button   button   = FindViewById <Button> (Resource.Id.myButton);
            EditText username = FindViewById <EditText> (Resource.Id.editText1);
            EditText password = FindViewById <EditText> (Resource.Id.editText2);

            // Twitter configuration part
            ConfigurationBuilder TwitterConfig = new ConfigurationBuilder();

            TwitterConfig.SetOAuthConsumerKey("_replace_wit_your_app_consumer_key_");
            TwitterConfig.SetOAuthConsumerSecret("_replace_wit_your_app_consumer_secret_");
            IConfiguration twiConfigInterface = TwitterConfig.Build();

            TwitterFactory factory = new TwitterFactory(twiConfigInterface);

            OAuthAuthorization oath = new OAuthAuthorization(twiConfigInterface);

            AccessToken ascTkn  = oath.GetOAuthAccessToken(username.Text, password.Text);
            ITwitter    twitter = factory.GetInstance(ascTkn);

            button.Click += delegate {
                ThreadPool.QueueUserWorkItem(state =>
                {
                    try
                    {
                        twitter.UpdateStatus("Hello world, Xamarin is exciting.. boom..");
                    }
                    catch (Exception ed)
                    {
                        Console.WriteLine(ed.Message);
                    }
                }
                                             );
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.MyButton);

            // TODO change OAuth keys and tokens and username and password

            ConfigurationBuilder config = new ConfigurationBuilder();

            config.SetOAuthConsumerKey("YourConsumerKey");
            config.SetOAuthConsumerSecret("YourConsumerSecret");
            config.SetOAuthAccessToken("YourAccessToken");
            config.SetOAuthAccessTokenSecret("YourAccessTokenSecret");
            config.SetUser("YouUsername");
            config.SetPassword("YourPassword");

            TwitterFactory factory = new TwitterFactory(config.Build());
            ITwitter       twitter = factory.Instance;

            button.Click += delegate
            {
                button.Text = string.Format("{0} clicks!", count++);
                ThreadPool.QueueUserWorkItem(state =>
                {
                    try
                    {
                        twitter.UpdateStatus("This is a test");
                    }
                    catch (Java.Lang.Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            };
        }
        private ActionResult SendUpdate(StatusViewModel model, OAuthToken token)
        {
            if (!TryValidateModel(model))
            {
                return(View("Send", model));
            }

            var twitterStatus = new TwitterStatus {
                Text = model.Status
            };

            //unit of work for db
            using (IRepository repository = Container.RepositoryFactory())
            {
                twitterStatus = repository.AddStatus(twitterStatus);
            }

            //twitter service operation
            ITwitter twitterClient = TwitterProvider.GetApi(token.Value, token.Secret);

            twitterClient.TimelineOperations.UpdateStatusAsync(twitterStatus.Text);

            return(RedirectToAction("View", new { id = twitterStatus.Id }));
        }
Пример #26
0
 public GetPBPTweetsService(string[] users, ITwitter twitter)
 {
     _users = users;
     _twitter = twitter;
 }
Пример #27
0
 public GetPBPTweetsService(string[] users, ITwitter twitter)
 {
     _users   = users;
     _twitter = twitter;
 }
Пример #28
0
 public TimeLineFactory(IContainer container, ITwitter twitter)
 {
     _container = container;
     _twitter = twitter;
 }
Пример #29
0
 public AppViewModel(ITwitter twitter, IDataBase data)
 {
     twitter            = new TwitterHelper();
     data               = new DataBasedHelper();
     _OpenWindowTwitter = new OpenWindowTwitter();
 }
Пример #30
0
 public static InfoPrinter GetInfoPrinter(ITwitter twitter) => new InfoPrinter(twitter.GetName(), twitter.GetAge(), twitter.GetFriendsCount());
Пример #31
0
 public VitaminKittyController(ICatFact catFact, IKittyImage kittyImage, ITwitter twitter)
 {
     _catFact    = catFact;
     _kittyImage = kittyImage;
     _twitter    = twitter;
 }
        public void UpdateStatus(string status)
        {
            ITwitter twitterClient = this.TwitterServiceProvider.GetApi(this.OAuthToken.Value, this.OAuthToken.Secret);

            twitterClient.TimelineOperations.UpdateStatusAsync(status, r => this.ShowHomeTimeline());
        }
        static void Main(string[] args)
        {
            try
            {
                TwitterServiceProvider twitterServiceProvider = new TwitterServiceProvider(TwitterConsumerKey, TwitterConsumerSecret);

#if NET_4_0
                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                Console.Write("Getting request token...");
                OAuthToken oauthToken = twitterServiceProvider.OAuthOperations.FetchRequestTokenAsync("oob", null).Result;
                Console.WriteLine("Done");

                string authenticateUrl = twitterServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                Console.WriteLine("Enter PIN Code from Twitter authorization page:");
                string pinCode = Console.ReadLine();

                Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken     = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken             oauthAccessToken = twitterServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
                Console.WriteLine("Done");

                /* API */

                ITwitter twitter = twitterServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

                twitter.UserOperations.GetUserProfileAsync("brbaia")
                .ContinueWith(task => Console.WriteLine("brbaia is " + task.Result.Name));

                // Use step by step debugging

/*
 *              // IBlockOperations
 *              TwitterProfile blockedProfile = twitter.BlockOperations.BlockAsync("brbaia").Result;
 *              CursoredList<TwitterProfile> blockedIserProfiles = twitter.BlockOperations.GetBlockedUsersAsync().Result;
 *              CursoredList<long> blockedUserIds = twitter.BlockOperations.GetBlockedUserIdsAsync().Result;
 *              blockedProfile = twitter.BlockOperations.UnblockAsync(blockedProfile.ID).Result;
 *
 *              // IDirectMessageOperations
 *              IList<DirectMessage> directMessagesSent = twitter.DirectMessageOperations.GetDirectMessagesSentAsync().Result;
 *              IList<DirectMessage> directMessagesReceived = twitter.DirectMessageOperations.GetDirectMessagesReceivedAsync().Result;
 *              DirectMessage directMessage = twitter.DirectMessageOperations.SendDirectMessageAsync("brbaia", "Hi from #Spring.NET Social Twitter!").Result;
 *              directMessage = twitter.DirectMessageOperations.GetDirectMessageAsync(directMessage.ID).Result;
 *              directMessage = twitter.DirectMessageOperations.DeleteDirectMessageAsync(directMessage.ID).Result;
 *
 *              // IFriendOperations
 *              CursoredList<TwitterProfile> followers = twitter.FriendOperations.GetFollowersAsync().Result;
 *              CursoredList<TwitterProfile> friends = twitter.FriendOperations.GetFriendsAsync().Result;
 *              TwitterProfile newFriend = twitter.FriendOperations.FollowAsync("brbaia").Result;
 *              twitter.FriendOperations.EnableNotificationsAsync("brbaia").Wait();
 *
 *              // IGeoOperations
 *              IList<Place> places = twitter.GeoOperations.SearchAsync(37.7821120598956, -122.400612831116).Result;
 *
 *              // IListOperations
 *              IList<UserList> myLists = twitter.ListOperations.GetListsAsync().Result;
 *              IList<UserList> s2Lists = twitter.ListOperations.GetListsAsync("SpringSource").Result;
 *              IList<TwitterProfile> listMembers = twitter.ListOperations.GetListMembersAsync(s2Lists[0].ID).Result;
 *              IList<TwitterProfile> listSubscribers = twitter.ListOperations.GetListSubscribersAsync(s2Lists[0].ID).Result;
 *              IList<Tweet> listTweets = twitter.ListOperations.GetListStatusesAsync(s2Lists[0].ID).Result;
 *              CursoredList<UserList> listMemberships = twitter.ListOperations.GetMembershipsAsync(listMembers[0].ID).Result;
 *              UserList myNewList = twitter.ListOperations.CreateListAsync("My list", "List description", true).Result;
 *              twitter.ListOperations.AddToListAsync(myNewList.ID, "brbaia").Wait();
 *              twitter.ListOperations.DeleteListAsync(myNewList.ID).Wait();
 *
 *              // ISearchOperations
 *              SearchResults searchResults = twitter.SearchOperations.SearchAsync("#spring").Result;
 *              SavedSearch savedSearch = twitter.SearchOperations.CreateSavedSearchAsync("@brbaia").Result;
 *              IList<SavedSearch> savedSearches = twitter.SearchOperations.GetSavedSearchesAsync().Result;
 *              twitter.SearchOperations.DeleteSavedSearchAsync(savedSearch.ID).Wait();
 *              Trends globalTrends = twitter.SearchOperations.GetTrendsAsync(1).Result;
 *
 *              // ITimelineOperations
 *              Tweet tweet = twitter.TimelineOperations.UpdateStatusAsync(
 *                  "Hi from #Spring.NET Social Twitter! http://bit.ly/x2rvlC", new AssemblyResource("Image.png", typeof(Program))).Result;
 *              twitter.TimelineOperations.DeleteStatusAsync(tweet.ID).Wait();
 *              IList<Tweet> homeTimeline = twitter.TimelineOperations.GetHomeTimelineAsync().Result;
 *              IList<Tweet> userTimeline = twitter.TimelineOperations.GetUserTimelineAsync().Result;
 *              IList<Tweet> mentions = twitter.TimelineOperations.GetMentionsAsync().Result;
 *              IList<Tweet> retweetsOfMe = twitter.TimelineOperations.GetRetweetsOfMeAsync().Result;
 *              IList<Tweet> retweets = twitter.TimelineOperations.GetRetweetsAsync(homeTimeline[0].ID).Result;
 *              IList<Tweet> favorites = twitter.TimelineOperations.GetFavoritesAsync().Result;
 *
 *              // IUserOperations
 *              TwitterProfile userProfile = twitter.UserOperations.GetUserProfileAsync().Result;
 *              IList<TwitterProfile> searchProfiles = twitter.UserOperations.SearchForUsersAsync("spring").Result;
 *              IList<RateLimitStatus> limits = twitter.UserOperations.GetRateLimitStatusAsync("users", "search", "statuses").Result;
 */
            }
            catch (AggregateException ae)
            {
                ae.Handle(ex =>
                {
                    if (ex is TwitterApiException)
                    {
                        Console.WriteLine(ex.Message);
                        return(true);
                    }
                    return(false);
                });
            }
#else
                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                Console.Write("Getting request token...");
                OAuthToken oauthToken = twitterServiceProvider.OAuthOperations.FetchRequestToken("oob", null);
                Console.WriteLine("Done");

                string authenticateUrl = twitterServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                Console.WriteLine("Enter PIN Code from Twitter authorization page:");
                string pinCode = Console.ReadLine();

                Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken oauthAccessToken         = twitterServiceProvider.OAuthOperations.ExchangeForAccessToken(requestToken, null);
                Console.WriteLine("Done");

                /* API */

                ITwitter twitter = twitterServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);

                TwitterProfile profile = twitter.UserOperations.GetUserProfile("brbaia");
                Console.WriteLine("brbaia is " + profile.Name);

                // Use step by step debugging

/*
 *              // IBlockOperations
 *              TwitterProfile blockedProfile = twitter.BlockOperations.Block("brbaia");
 *              CursoredList<TwitterProfile> blockedIserProfiles = twitter.BlockOperations.GetBlockedUsers();
 *              CursoredList<long> blockedUserIds = twitter.BlockOperations.GetBlockedUserIds();
 *              blockedProfile = twitter.BlockOperations.Unblock(blockedProfile.ID);
 *
 *              // IDirectMessageOperations
 *              IList<DirectMessage> directMessagesSent = twitter.DirectMessageOperations.GetDirectMessagesSent();
 *              IList<DirectMessage> directMessagesReceived = twitter.DirectMessageOperations.GetDirectMessagesReceived();
 *              DirectMessage directMessage = twitter.DirectMessageOperations.SendDirectMessage("brbaia", "Hi from #Spring.NET Social Twitter!");
 *              directMessage = twitter.DirectMessageOperations.GetDirectMessage(directMessage.ID);
 *              directMessage = twitter.DirectMessageOperations.DeleteDirectMessage(directMessage.ID);
 *
 *              // IFriendOperations
 *              CursoredList<TwitterProfile> followers = twitter.FriendOperations.GetFollowers();
 *              CursoredList<TwitterProfile> friends = twitter.FriendOperations.GetFriends();
 *              TwitterProfile newFriend = twitter.FriendOperations.Follow("brbaia");
 *              twitter.FriendOperations.EnableNotifications("brbaia");
 *
 *              // IGeoOperations
 *              IList<Place> places = twitter.GeoOperations.Search(37.7821120598956, -122.400612831116);
 *
 *              // IListOperations
 *              IList<UserList> myLists = twitter.ListOperations.GetLists();
 *              IList<UserList> s2Lists = twitter.ListOperations.GetLists("SpringSource");
 *              IList<TwitterProfile> listMembers = twitter.ListOperations.GetListMembers(s2Lists[0].ID);
 *              IList<TwitterProfile> listSubscribers = twitter.ListOperations.GetListSubscribers(s2Lists[0].ID);
 *              IList<Tweet> listTweets = twitter.ListOperations.GetListStatuses(s2Lists[0].ID);
 *              CursoredList<UserList> listMemberships = twitter.ListOperations.GetMemberships(listMembers[0].ID);
 *              UserList myNewList = twitter.ListOperations.CreateList("My list", "List description", true);
 *              twitter.ListOperations.AddToList(myNewList.ID, "brbaia");
 *              twitter.ListOperations.DeleteList(myNewList.ID);
 *
 *              // ISearchOperations
 *              SearchResults searchResults = twitter.SearchOperations.Search("#spring");
 *              SavedSearch savedSearch = twitter.SearchOperations.CreateSavedSearch("@brbaia");
 *              IList<SavedSearch> savedSearches = twitter.SearchOperations.GetSavedSearches();
 *              twitter.SearchOperations.DeleteSavedSearch(savedSearch.ID);
 *              Trends globalTrends = twitter.SearchOperations.GetTrends(1);
 *
 *              // ITimelineOperations
 *              Tweet tweet = twitter.TimelineOperations.UpdateStatus(
 *                  "Hi from #Spring.NET Social Twitter! http://bit.ly/x2rvlC", new AssemblyResource("Image.png", typeof(Program)));
 *              twitter.TimelineOperations.DeleteStatus(tweet.ID);
 *              IList<Tweet> homeTimeline = twitter.TimelineOperations.GetHomeTimeline();
 *              IList<Tweet> userTimeline = twitter.TimelineOperations.GetUserTimeline();
 *              IList<Tweet> mentions = twitter.TimelineOperations.GetMentions();
 *              IList<Tweet> retweetsOfMe = twitter.TimelineOperations.GetRetweetsOfMe();
 *              IList<Tweet> retweets = twitter.TimelineOperations.GetRetweets(homeTimeline[0].ID);
 *              IList<Tweet> favorites = twitter.TimelineOperations.GetFavorites();
 *
 *              // IUserOperations
 *              TwitterProfile userProfile = twitter.UserOperations.GetUserProfile();
 *              IList<TwitterProfile> searchProfiles = twitter.UserOperations.SearchForUsers("spring");
 *              IList<RateLimitStatus> limits = twitter.UserOperations.GetRateLimitStatus("users", "search", "statuses");
 */
            }
Пример #34
0
 public TwitterService(ITwitter twitter)
 {
     this.twitter = twitter;
 }
Пример #35
0
        static void Main(string[] args)
        {
#if NET_4_0
            try
            {
                TwitterServiceProvider twitterServiceProvider = new TwitterServiceProvider(TwitterConsumerKey, TwitterConsumerSecret);

                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                Console.Write("Getting request token...");
                OAuthToken oauthToken = twitterServiceProvider.OAuthOperations.FetchRequestTokenAsync("oob", null).Result;
                Console.WriteLine("Done");

                string authenticateUrl = twitterServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                Console.WriteLine("Enter PIN Code from Twitter authorization page:");
                string pinCode = Console.ReadLine();

                Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken     = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken             oauthAccessToken = twitterServiceProvider.OAuthOperations.ExchangeForAccessTokenAsync(requestToken, null).Result;
                Console.WriteLine("Done");

                /* API */

                ITwitter twitter = twitterServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
                Console.WriteLine("Enter your status message:");
                string message = Console.ReadLine();

                twitter.UpdateStatusAsync(message).Wait();
                Console.WriteLine("Status updated!");
            }
            catch (AggregateException ae)
            {
                ae.Handle(ex =>
                {
                    if (ex is HttpResponseException)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine(((HttpResponseException)ex).GetResponseBodyAsString());
                        return(true);
                    }
                    return(false);
                });
            }
#else
            try
            {
                TwitterServiceProvider twitterServiceProvider = new TwitterServiceProvider(TwitterConsumerKey, TwitterConsumerSecret);

                /* OAuth 'dance' */

                // Authentication using Out-of-band/PIN Code Authentication
                Console.Write("Getting request token...");
                OAuthToken oauthToken = twitterServiceProvider.OAuthOperations.FetchRequestToken("oob", null);
                Console.WriteLine("Done");

                string authenticateUrl = twitterServiceProvider.OAuthOperations.BuildAuthorizeUrl(oauthToken.Value, null);
                Console.WriteLine("Redirect user for authentication: " + authenticateUrl);
                Process.Start(authenticateUrl);
                Console.WriteLine("Enter PIN Code from Twitter authorization page:");
                string pinCode = Console.ReadLine();

                Console.Write("Getting access token...");
                AuthorizedRequestToken requestToken     = new AuthorizedRequestToken(oauthToken, pinCode);
                OAuthToken             oauthAccessToken = twitterServiceProvider.OAuthOperations.ExchangeForAccessToken(requestToken, null);
                Console.WriteLine("Done");

                /* API */

                ITwitter twitter = twitterServiceProvider.GetApi(oauthAccessToken.Value, oauthAccessToken.Secret);
                Console.WriteLine("Enter your status message:");
                string message = Console.ReadLine();

                twitter.UpdateStatus(message);
                Console.WriteLine("Status updated!");
            }
            catch (HttpResponseException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.GetResponseBodyAsString());
            }
#endif
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("--- hit <return> to quit ---");
                Console.ReadLine();
            }
        }
 public TwitterService(ITwitter twitter)
 {
     this.twitter = twitter;
 }
Пример #37
0
        public static void Init()
        {
            twitterGameObject = new GameObject ("TwitterGameObject");
            twitterGameObject.AddComponent<TwitterComponent> ();

            #if UNITY_IOS && !UNITY_EDITOR
            twitter = new IOSTwitterImpl();
            #elif UNITY_ANDROID && !UNITY_EDITOR
            twitter = new AndroidTwitterImpl();
            #else
            twitter = new EditorTwitterImpl();
            #endif
        }
 public CallbackMessageHandler(ITwitter twitter)
 {
     _twitter = twitter ?? throw new ArgumentNullException(nameof(twitter));
 }
Пример #39
0
 public void TestFixtureSetUp()
 {
     _twitter = new Twitter(Settings.Default.ConsumerKey, Settings.Default.ConsumerSecret);
     _user = "******";
 }
Пример #40
0
        private static void RunRavenIIS(ITwitter ctx, string twitterHandle)
        {
            using (var store = new DocumentStore
            {
                ConnectionStringName = ConfigurationManager.ConnectionStrings["RavenDbSocialTrailsSecure"].Name
            })
            {
                store.Initialize();
                Console.Write("RavenDb Embedded Document Store Initialized Successfully.");

                PerformInitialTimelineLoad(store, ctx, twitterHandle);

                Console.ReadKey();
            }
        }
Пример #41
0
 public FeedbackController(ISupportTicketService support, ITwitter twitter)
 {
     _support = support;
     _twitter = twitter;
 }
Пример #42
0
 public void AddMethod(ITwitter twitter)
 {
     this.twitters.Add(twitter);
 }
Пример #43
0
 public TwitterWindowViewModel(ITwitter twitter, IDataBase dataBase)
 {
     twitterService  = twitter;
     dataBaseService = dataBase;
 }
Пример #44
0
 public KanReportsProvider(HttpClient client = null)
 {
     _twitter = new Twitter(client);
 }