コード例 #1
0
		private async static void XAuthTestWithLinqToTwitter()
		{
			Console.WriteLine("Enter User Name...");
			string userName = Console.ReadLine();
			Console.WriteLine("Enter Password...");
			string password = Console.ReadLine();

			var auth = new XAuthAuthorizer
			{
				CredentialStore = new XAuthCredentials
				{
					ConsumerKey = OAuthProperties.ConsumerKey,
					ConsumerSecret = OAuthProperties.ConsumerKeySecret,
					UserName = userName,
					Password = password
				}
			};

			try
			{
				await auth.AuthorizeAsync();
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex);
			}

			using (var twitterCtx = new TwitterContext(auth))
			{
				//Log
				twitterCtx.Log = Console.Out;

				List<LinqToTwitter.User> users =
					(from	tweet in twitterCtx.User
					 where	tweet.Type == UserType.Show 
							&& tweet.ScreenName == "JoeMayo"
					 select tweet)
					.ToList();

				users.ForEach(user =>
				{
					var status =
						user.Protected || user.Status == null ?
							"Status Unavailable" :
							user.Status.Text;

					Console.WriteLine(
						"ID: {0}, Name: {1}\nLast Tweet: {2}\n",
						user.UserID, user.ScreenName, status);
				});
			}
		}
コード例 #2
0
        private static TwitterContext GetTwitterContext()
        {
            var auth = new XAuthAuthorizer()
            {
                CredentialStore = new InMemoryCredentialStore
                {
                    ConsumerKey = "rsrleZR4jRNIN0Cm7uPGxOpWy",
                    ConsumerSecret = "ij1N7CcRwPtbe76RFdon8ruCJEMNVFJ4n03AKbVDMjzAFqbPqs",
                    OAuthToken = App.UserInfo.Token,
                    OAuthTokenSecret = App.UserInfo.TokenSecret,
                    ScreenName = App.UserInfo.ScreenName,
                    UserID = ulong.Parse(App.UserInfo.TwitterId)
                },
            };
            auth.AuthorizeAsync();

            var ctx = new TwitterContext(auth);
            return ctx;
        }
コード例 #3
0
        private static TwitterContext GetTwitterContext()
        {
            var auth = new XAuthAuthorizer()
            {
                CredentialStore = new InMemoryCredentialStore
                {
                    ConsumerKey = "Twitter Consumer Key",
                    ConsumerSecret = "Twitter Consumer Secret",
                    OAuthToken = App.User.Token,
                    OAuthTokenSecret = App.User.TokenSecret,
                    ScreenName = App.User.ScreenName,
                    UserID = ulong.Parse(App.User.TwitterId)
                },
            };
            auth.AuthorizeAsync();

            var ctx = new TwitterContext(auth);
            return ctx;
        }
コード例 #4
0
        private static TwitterContext GetTwitterContext()
        {
            var auth = new XAuthAuthorizer()
            {
                CredentialStore = new InMemoryCredentialStore
                {
                    ConsumerKey = "B86OgAiSUnxXYXsspdJpvWuKH",
                    ConsumerSecret = "uyHG0czAlBuXTnjjxOv3EIGDhZ0M9mg92JexjPUqYMZRLVSotW",
                    OAuthToken = App.User.Token,
                    OAuthTokenSecret = App.User.TokenSecret,
                    ScreenName = App.User.ScreenName,
                    UserID = ulong.Parse(App.User.TwitterId)
                },
            };
            auth.AuthorizeAsync();

            var ctx = new TwitterContext(auth);
            return ctx;
        }
コード例 #5
0
		private TwitterContext GetTwitterContext(string serializeInfo = "")
		{
			TwitterData.TwitterUser user = JsonConvert.DeserializeObject<TwitterData.TwitterUser>(serializeInfo);
			var auth = new XAuthAuthorizer()
			{
				//CredentialStore = new InMemoryCredentialStore
				//{
				//	ConsumerKey = "YVgafJLg6figpxcFTx9oBhXDw",
				//	ConsumerSecret = "AdNdiuHSHIf5hN6HWnVrC9u6bnW3vVirjEhAFrfabacPIQdh98",
				//	OAuthToken = "3620214675-KzcSqmYy131LlcQGe8nOptxCdQCBP8ajPYXYwvl",
				//	OAuthTokenSecret = "GycvXtklGfaYz1WjOINEhkmZr6OwGDz38SUX68iCMWv9f",
				//	ScreenName = "bogdanm__",
				//	UserID = 3620214675
				//},
				CredentialStore = new InMemoryCredentialStore
				{
					ConsumerKey = "YVgafJLg6figpxcFTx9oBhXDw",
					ConsumerSecret = "AdNdiuHSHIf5hN6HWnVrC9u6bnW3vVirjEhAFrfabacPIQdh98",
					OAuthToken = "3620214675-KzcSqmYy131LlcQGe8nOptxCdQCBP8ajPYXYwvl",
					OAuthTokenSecret = "GycvXtklGfaYz1WjOINEhkmZr6OwGDz38SUX68iCMWv9f",
					ScreenName = user == null ? String.Empty : user.ScreenName,
					UserID = user == null ? 0 : user.UserID
				},
			};
			auth.AuthorizeAsync();

			var ctx = new TwitterContext(auth);
			return ctx;
		}
コード例 #6
0
ファイル: Program.cs プロジェクト: prog-moh/LinqToTwitter
        static IAuthorizer DoXAuth()
        {
            var auth = new XAuthAuthorizer
            {
                CredentialStore = new XAuthCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"],
                    UserName = "******",
                    Password = "******"
                }
            };

            return auth;
        }
コード例 #7
0
        private void DoXAuth()
        {
            WebBrowser.Visibility = Visibility.Collapsed;
            PinPanel.Visibility = Visibility.Collapsed;

            var auth = new XAuthAuthorizer
            {
                Credentials = new XAuthCredentials
                {
                    ConsumerKey = "",
                    ConsumerSecret = "",
                    UserName = "",
                    Password = ""
                }
            };

            auth.BeginAuthorize(resp =>
                Dispatcher.BeginInvoke(() =>
                {
                    switch (resp.Status)
                    {
                        case TwitterErrorStatus.Success:
                            FriendsPanel.Visibility = Visibility.Visible;
                            break;
                        case TwitterErrorStatus.TwitterApiError:
                        case TwitterErrorStatus.RequestProcessingException:
                            MessageBox.Show(
                                resp.Error.ToString(),
                                resp.Message,
                                MessageBoxButton.OK);
                            break;
                    }
                }));

            m_twitterCtx = new TwitterContext(auth);
        }
コード例 #8
0
ファイル: Twitter.cs プロジェクト: xarrez/LiveSplit
        static ITwitterAuthorizer DoXAuth(string username, string password)
        {
            var auth = new XAuthAuthorizer
            {
                Credentials = new XAuthCredentials
                {
                    ConsumerKey = ConsumerKey,
                    ConsumerSecret = ConsumerSecret,
                    UserName = username,
                    Password = password
                }
            };

            return auth;
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: prog-moh/LinqToTwitter
        static IAuthorizer DoXAuth()
        {
            var auth = new XAuthAuthorizer
            {
                CredentialStore = new XAuthCredentials
                {
                    ConsumerKey = Environment.GetEnvironmentVariable(OAuthKeys.TwitterConsumerKey),
                    ConsumerSecret = Environment.GetEnvironmentVariable(OAuthKeys.TwitterConsumerSecret),
                    UserName = "******",
                    Password = "******"
                }
            };

            return auth;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: CheyPMK/linqtotwitter
        static ITwitterAuthorizer DoXAuth()
        {
            // validate that credentials are present
            if (ConfigurationManager.AppSettings["twitterConsumerKey"].IsNullOrWhiteSpace() ||
                ConfigurationManager.AppSettings["twitterConsumerSecret"].IsNullOrWhiteSpace())
            {
                Console.WriteLine("You need to set twitterConsumerKey and twitterConsumerSecret in App.config/appSettings. Visit http://dev.twitter.com/apps for more info.\n");
                Console.Write("Press any key to exit...");
                Console.ReadKey();
                return null;
            }

            // configure the OAuth object
            var auth = new XAuthAuthorizer
            {
                Credentials = new XAuthCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"],
                    UserName = "******",
                    Password = "******"
                }
            };

            // authorize with Twitter
            auth.Authorize();

            return auth;
        }
コード例 #11
0
        private XAuthAuthorizer GetXAuthAuthorizer()
        {
            var auth = new XAuthAuthorizer
                       {
                          Credentials = new XAuthCredentials
                                           {
                                              ConsumerKey = ConfigurationSettings.AppSettings["ConsumerKey"],
                                              ConsumerSecret = ConfigurationSettings.AppSettings["ConsumerSecret"],
                                              AccessToken = ConfigurationSettings.AppSettings["TokenSecret"],
                                              OAuthToken = ConfigurationSettings.AppSettings["Token"]
                                           }
                       };

             auth.Authorize();
             return auth;
        }