gpt4 book ai didi

api - Twitter API 资源 URL 格式中的冒号是什么意思?

转载 作者:行者123 更新时间:2023-12-02 04:37:41 43 4
gpt4 key购买 nike

用于转推的 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 路径的一部分并作为参数传递?显得多余。

谢谢

-玛莲娜

最佳答案

假设您要转发 ID 为 123456 的推文。该数字是 :id

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

所以你可以拥有

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

关于api - Twitter API 资源 URL 格式中的冒号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21595420/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com