1

我正在使用 TweetSharp 为 twitter 制作一个小型演示桌面应用程序,并且我正在使用以下代码来获取登录用户的所有消息:-

TwitterService service = new TwitterService("ConsumerKey", "ConsumerSecretKey");
// Step 1 - Retrieve an OAuth Request Token
OAuthRequestToken requestToken = service.GetRequestToken();

// Step 2 - Redirect to the OAuth Authorization URL
Uri uri = service.GetAuthorizationUri(requestToken);
Process.Start(uri.ToString());

// Step 3 - Exchange the Request Token for an Access Token
Console.Write("Enter Pin:: ");
string verifier = Console.ReadLine(); // <-- This is input into your application by your user

OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

// Step 4 - User authenticates using the Access Token
service.AuthenticateWith(access.Token, access.TokenSecret);

string message = null;

List<string> messages = new List<string>();

IEnumerable<TwitterDirectMessage> directMessages = service.ListDirectMessagesReceived(new ListDirectMessagesReceivedOptions());

//Fetch all current direct message:
foreach (TwitterDirectMessage directMessage in directMessages)
{
    //Write All Messages in Console
    Console.WriteLine(directMessage.Text);
}

上面的 foreach 循环将显示所有消息,但我的问题是,当任何其他用户向我发送新消息时,如何通知我新消息。

请帮我!

任何帮助表示赞赏!

谢谢!

4

1 回答 1

2

此 TweetSharp 代码定义了库方法。

于 2013-08-14T08:47:34.523 回答