【问题标题】:MGTwitterEngine is not returning re-tweets, only “original” tweetsMGTwitterEngine 不返回转发推文,只返回“原始”推文
【发布时间】:2011-10-29 01:08:19
【问题描述】:

我是 iPhone 应用程序开发的新手,正在尝试创建基于 Twitter 的 iPhone 应用程序。 我正在使用MGTwitterEngine 来搜索和检索我关注的人的时间线。 我使用的方法是:

[twitterEngine getFollowedTimelineSinceID:0 startingAtPage:0 count:100]; 

一切都很好,但有几件事让我很苦恼:

  1. 我只收到最初由我的关注列表发布的推文,根本没有转发推文。我真的很想在同一个电话中获取所有推文(原始推文和转发推文),但如果我需要执行两个请求(一个用于推文,一个用于转发推文),这对我来说也可以。李>
  2. 我收到的推文不到 100 条,但我知道我关注的人发布的推文不止这些。知道如何解决吗?

有人提到MGTwitterEngine 缺少转发推文功能。我不是想转发推文,而只是为了获得完整的时间表(包括我关注的人转发推文)。

非常感谢!

【问题讨论】:

  • 你看过 MG 源代码,看看它为 getFollowed 做了什么 api 调用...我会这样做,然后查看 twitter API 文档以确保转发甚至应该回来打那个电话。
  • 谢谢 shawnwall,我来看看 getFollowed 执行的实际 api 调用。关于 Twitter API - 看起来 Twitter API 确实支持获取转发。

标签: iphone twitter mgtwitterengine


【解决方案1】:

看看这个https://dev.twitter.com/docs/api/1/get/statuses/home_timeline

具体看说的部分:

Include_RTS : When set to either true, t or 1,the timeline will contain native retweets (if they exist) in addition to the standard stream of tweets...

现在在 getFollowedTimelineSinceID 方法中,您需要为 params 字典创建一个新对象

[params setObject:[NSString stringWithFormat:@"%@", @"true"] forKey:@"Include_RTS"];

【讨论】:

  • 感谢@bizsytes 的工作就像一个魅力。根据您的建议,我对 getFollowedTimelineSinceID 进行了两项修改: 1. 将路径字符串从 @statuses/friends_timeline.%@ 更改为 @statuses/home_timeline.%@ 2. 添加了 Include_RTS 对象 显然它解决了我的两个问题(转发和数量检索到的状态)。
  • 哦,是的,我没有说任何关于friend_timeline 被弃用的事情,因为那不是最初的问题。 +1 用于自己解决所有问题 :) 另外,您可以添加任何其他参数,例如,您可以添加一个以了解您是否转发了特定推文。默认返回的 retweeted 参数始终为 false,还有另一种解决方法可以确定推文是否已被您转发。
【解决方案2】:

根据@bizsytes 的建议,我对 MGTwitterEngine 的 getFollowedTimelineSinceID 方法:

  1. 将路径字符串从@statuses/friends_timeline.%@ 更改为@statuses/home_timeline.%@

  2. 添加了 Include_RTS 对象

显然它解决了我的两个问题(转发和检索到的状态数量)。

现在该方法如下所示:

- (NSString *)getAllFollowedTimelineSinceID:(unsigned long)sinceID withMaximumID:(unsigned long)maxID startingAtPage:(int)page count:(int)count
{
    NSString *path = [NSString stringWithFormat:@"statuses/home_timeline.%@", API_FORMAT];

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
    if (sinceID > 0) {
        [params setObject:[NSString stringWithFormat:@"%u", sinceID] forKey:@"since_id"];
    }
    if (maxID > 0) {
        [params setObject:[NSString stringWithFormat:@"%u", maxID] forKey:@"max_id"];
    }
    if (page > 0) {
        [params setObject:[NSString stringWithFormat:@"%d", page] forKey:@"page"];
    }
    if (count > 0) {
        [params setObject:[NSString stringWithFormat:@"%d", count] forKey:@"count"];
    }

    [params setObject:[NSString stringWithFormat:@"%@", @"true"] forKey:@"Include_RTS"];


    return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil 
                            requestType:MGTwitterFollowedTimelineRequest 
                           responseType:MGTwitterStatuses];
}

【讨论】:

    猜你喜欢
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 2018-07-04
    • 2019-02-07
    • 2018-09-01
    相关资源
    最近更新 更多