没有从 MGTwitterEngine 获得委托回调

发布于 2024-11-04 09:40:30 字数 412 浏览 3 评论 0原文

我正在尝试通过 MGTwitterEngine 获取 twitter 用户的 sentDirectMessages。但是,我没有收到来自引擎的 MGTwitterEngine 委托方法回调来说明其收到的数据。

我放置了一个 NSLog 来查看是否调用了 connectionFinished 方法,确实如此,但没有其他方法,即 - (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)connectionIdentifier

请你能告诉我问题是什么吗,所有代表都设置为自我。

 [manager.engine getSentDirectMessagesSinceID:0 startingAtPage:0];

I am trying to get the sentDirectMessages of a twitter user via MGTwitterEngine. However, I am not receiving an MGTwitterEngine delegation method callback from the engine to say its received data.

I put an NSLog to see if the connectionFinished method was being called, and it was, but no other methods were i.e - (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)connectionIdentifier

Please could you tell me what the problem is, all delegates are set to self.

 [manager.engine getSentDirectMessagesSinceID:0 startingAtPage:0];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傾城如夢未必闌珊 2024-11-11 09:40:30
  1. 抱歉,但我会问常规问题:您的 .h 文件中是否有 MGTwitterEngineDelegate?

  2. 我建议在 requestSucceeded:requestFailed:withError: 中添加一些日志记录

  3. 您是否在该项目中成功进行了任何其他类型的 Twitter 通信?在同一类中?

编辑

我设置了一个 DM 请求,它与 requestSucceeded:directMessagesReceived:forRequest: 一起正常工作,

基于您的:

“所以每次我想得到 dm 的
用户的,我必须得到
用户注销然后再次登录。”

我想知道这是否不是用户令牌未正确存储的问题?我建议研究一下成功登录如何存储令牌?

特别是这个 MGTwitterEngineDelegate 方法。

- (void)accessTokenReceived:(OAToken *)aToken forRequest:(NSString *)connectionIdentifier
{
    NSLog(@"Access token received! %@",aToken);
    [manager.engine setAccessToken:aToken];

    //I have an OAToken variable called "token" defined in my .h
    token = [aToken retain];

    NSLog(@"storing token in userdefaults");

    //this line is key for maintaining a login token throughout the app
    //even when the user closes the app and comes back
    [token storeInUserDefaultsWithServiceProviderName:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] prefix:@"twitter"];

    //call your dm or whatever methods for after login here
    .
    .
    .
}

希望这会有所帮助。

  1. Sry, but I will ask the routine question: Do you have MGTwitterEngineDelegate in your .h file?

  2. I suggest throwing some logging in requestSucceeded: and requestFailed:withError:

  3. Are you successfully doing any other types of Twitter communication within that project? within the same class?

EDIT

I setup a DM request and it worked correctly with a requestSucceeded: and a directMessagesReceived:forRequest:

Based on your:

"So everytime I want to get the dm's
of the user, I will have to get the
user to logout and then login again."

I am wondering if this is not an issue where the users token is not being stored correctly? I suggest look into how the successful login is storing the token?

In particular this MGTwitterEngineDelegate method.

- (void)accessTokenReceived:(OAToken *)aToken forRequest:(NSString *)connectionIdentifier
{
    NSLog(@"Access token received! %@",aToken);
    [manager.engine setAccessToken:aToken];

    //I have an OAToken variable called "token" defined in my .h
    token = [aToken retain];

    NSLog(@"storing token in userdefaults");

    //this line is key for maintaining a login token throughout the app
    //even when the user closes the app and comes back
    [token storeInUserDefaultsWithServiceProviderName:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] prefix:@"twitter"];

    //call your dm or whatever methods for after login here
    .
    .
    .
}

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文