如何解决 Cocoa 应用程序中 MgTwitter 的 xAuth 问题?
我正在为 Mac OSX 开发 Twitter 客户端,并且使用 MgTwitter 框架。 我使用 xAuth 登录方法,它工作正常,但我无法从我的时间线获取推文。
这是控制台中的错误消息:
+[OARequestParameter requestParameter:value:]: unrecognized selector sent to class
这是登录方法的代码和管理令牌元素的函数:
- (void)startTwitter {
NSLog(@"Starting twitter connection...");
NSString *consumerKey = @"***************";
NSString *consumerSecret = @"*********";
twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterEngine setUsesSecureConnection:NO];
[twitterEngine setConsumerKey:consumerKey secret:consumerSecret];
[twitterEngine setUsername:user];
// xAuth method
[twitterEngine getXAuthAccessTokenForUsername:user password:password];
// update timeline
[self updateTwitterBuffer];
} // startTwitter
- (void) updateTwitterBuffer {
NSLog(@"Updating timeline.");
[twitterEngine getHomeTimelineSinceID:0 startingAtPage:0 count:20];
[twitterEngine getDirectMessagesSinceID:0 startingAtPage:0];
[twitterEngine getSentDirectMessagesSinceID:0 startingAtPage:0];
} // updateTwitterBuffer
- (void) stopTwitter {
[twitterEngine release];
[token release];
} // stopTwitter
- (void)accessTokenReceived:(OAToken *)aToken forRequest:(NSString *)connectionIdentifier {
NSLog(@"Access token received! %@",aToken);
token = [aToken retain];
[twitterEngine setAccessToken:token];
} // accessTokenReceived
我不知道错误在哪里。我该如何解决?多谢。
I am developing a Twitter client for Mac OSX and I am using MgTwitter framework.
I use xAuth login method and it works fine but I can't get tweets from my timeline.
Here is the error message in the console:
+[OARequestParameter requestParameter:value:]: unrecognized selector sent to class
And here is the code for login method and the functions to manage the token element:
- (void)startTwitter {
NSLog(@"Starting twitter connection...");
NSString *consumerKey = @"***************";
NSString *consumerSecret = @"*********";
twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterEngine setUsesSecureConnection:NO];
[twitterEngine setConsumerKey:consumerKey secret:consumerSecret];
[twitterEngine setUsername:user];
// xAuth method
[twitterEngine getXAuthAccessTokenForUsername:user password:password];
// update timeline
[self updateTwitterBuffer];
} // startTwitter
- (void) updateTwitterBuffer {
NSLog(@"Updating timeline.");
[twitterEngine getHomeTimelineSinceID:0 startingAtPage:0 count:20];
[twitterEngine getDirectMessagesSinceID:0 startingAtPage:0];
[twitterEngine getSentDirectMessagesSinceID:0 startingAtPage:0];
} // updateTwitterBuffer
- (void) stopTwitter {
[twitterEngine release];
[token release];
} // stopTwitter
- (void)accessTokenReceived:(OAToken *)aToken forRequest:(NSString *)connectionIdentifier {
NSLog(@"Access token received! %@",aToken);
token = [aToken retain];
[twitterEngine setAccessToken:token];
} // accessTokenReceived
I don't know where the error is. How can I solve it? Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读上面的代码非常困难:它很混乱。我建议稍微格式化一下。
以下是使用 MGTwitterEngine 的系列链接,并引导您逐步使用它来创建自己的 Twitter 应用程序: http://brandontreb.com/creating-a-twitter-client-for-osx-part-1/
我建议通过该步骤获得更好地了解图书馆的运作方式。
It's extremely difficult to read your code above: it's jumbled. I'd recommend formatting it a bit.
Here's a link to a series that uses the MGTwitterEngine and takes you through using it step by step to create your own twitter application: http://brandontreb.com/creating-a-twitter-client-for-osx-part-1/
I'd recommend going through that to get a better understanding of how the library works.