【问题标题】:what does the colon mean in the Twitter API Resource URL format?Twitter API 资源 URL 格式中的冒号是什么意思?
【发布时间】:2014-02-06 18:10:41
【问题描述】:

用于转推的 Twitter API 显示为以下资源 URL:

http://api.twitter.com/1/statuses/retweet/:id.format

然后它说“id”是必需的参数。

因此,基于此,我认为以下 AIFNetworking 调用会起作用。我设置的地方: postPath:@"1.1/statuses/retweet.json"

和参数: NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:@{@"id": tweetID}];

整个调用看起来像:

- (void)postARetweet:(NSString*)tweetID success:(void (^)(AFHTTPRequestOperation *operation, id response))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure {

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:@{@"id": tweetID}];
self postPath:@"1.1/statuses/retweet.json" parameters:params success:success failure:failure];}

但我收到一个 404 错误,告诉我该页面不存在。经过多次试验和错误,我强制 postPath 是

postpath:@"1.1/statuses/retweet/@"some_tweet_number".json"

这很奏效。

所以我不明白为什么“id”键的“params”条目没有按照它应该的方式附加到原始 postpath 中。我唯一的想法是,也许 postpath 必须包含“id”以及相同的“id”作为参数。

那么资源 URL 中的 :id 是什么意思? 为什么 API 需要将推文的“id”作为 URL 路径的一部分并作为参数传递?似乎是多余的。

谢谢

-玛莲娜

【问题讨论】:

    标签: api url twitter


    【解决方案1】:

    假设您想转发一条 ID 为 123456 的推文。该号码是:id

    现在,假设您希望响应采用 XML 格式。那是format

    所以你可以拥有

    https://api.twitter.com/1.1/statuses/retweet/123456.xml
    

    https://api.twitter.com/1.1/statuses/retweet/123456.json
    

    请注意,API 已更改为 1.1 版。你应该仔细阅读https://api.twitter.com/1.1/的文档

    有关转推文档,请参阅https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/%3Aid

    【讨论】:

    • 如果您觉得我的回答有用,请点赞或接受。谢谢:-)
    猜你喜欢
    • 2020-05-21
    • 2012-10-09
    • 2021-11-25
    • 1970-01-01
    • 2019-09-14
    • 2012-09-25
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多