Twitter API请求的名称趋势(按名称搜索)

问题描述 投票:1回答:1

如果没有API允许通过特定名称进行请求,我该如何执行此过程任何想法

c# asp.net-mvc api twitter
1个回答
0
投票

那里运气不好。 Twitter API公开了两个用于搜索趋势的端点:

  1. trends/locations获取有趋势的可用位置
  2. trends/place以获取所述位置的热门话题

如果有趋势信息,则返回特定WOEID的前50个趋势主题。

响应是趋势对象的数组,这些对象编码趋势主题的名称,可用于在Twitter Search上搜索主题的查询参数以及Twitter搜索URL。

此信息被缓存5分钟。要求更多的次数将不会返回更多数据,并且将计入速率限制使用。

如果有可用的趋势,还会返回最近24小时的tweet_volume。

尽管查看返回示例:

"trends": [
      {
        "name": "#ChainedToTheRhythm",
        "url": "http://twitter.com/search?q=%23ChainedToTheRhythm",
        "promoted_content": null,
        "query": "%23ChainedToTheRhythm",
        "tweet_volume": 48857
      }

如果您要像这样上课:

public class Trend {
    public string name {get; set;}
    public string url {get; set;}
    // etc
}

然后将数组deserialize移至列表List<Trend>,可以在内存linq中使用它按名称搜索

    var trends = JsonConvert.DeserializeObject<TrendsResponse>(json);
    var newTrendList = trends.Where(t = t.name.Contains("targetName")).ToList();
© www.soinside.com 2019 - 2024. All rights reserved.