问题描述
限时送ChatGPT账号..我正在为没有 Twitter 的用户构建应用程序,因此无法进行用户身份验证.我让它与用户时间线一起工作,但不能与搜索一起工作.
I am building a app for users who don't have Twitter, so user authentication is impossible. I got it working with the user timeline but not with search.
我从 Twitter 收到了这个错误:
I got this error back from Twitter:
{"errors":[{"message":"Could not authenticate you","code":32}]}
这是我的代码:
MKNetworkOperation *operation = [[MKNetworkOperation alloc] initWithURLString:@"https://api.twitter/1.1/statuses/user_timeline.json" params:[@{ @"screen_name" : user } mutableCopy] httpMethod:@"GET"];
[operation addHeaders:@{ @"Authorization" : [self OAuthHeaderForURL:[NSURL URLWithString:operation.url]] }];
[operation onCompletion:^(MKNetworkOperation *completedOperation) {
completionBlock([completedOperation responseJSON]);
} onError:^(NSError *error) {
NSLog(@"\n\n\nError bij User: %@", error);
}];
[selfworkEngine enqueueOperation:operation];
这是有问题的代码:
MKNetworkOperation *operation = [[MKNetworkOperation alloc] initWithURLString:@"https://api.twitter/1.1/search/tweets.json" params:[@{ @"q" : [NSString stringWithFormat:@"#%@", hashtag] } mutableCopy] httpMethod:@"GET"];
[operation addHeaders:@{ @"Authorization" : [self OAuthHeaderForURL:[NSURL URLWithString:operation.url]] }];
[operation onCompletion:^(MKNetworkOperation *completedOperation) {
completionBlock([completedOperation responseJSON]);
} onError:^(NSError *error) {
NSLog(@"\n\n\nError bij Hashtag: %@", error);
}];
[selfworkEngine enqueueOperation:operation];
这是 cURL 命令行字符串:
Here is the cURL command line string:
curl -X GET -H "Authorization: OAuth oauth_consumer_key="XizVPuR2LQcnL9xAzMo6AA", oauth_nonce="2806C6BC-5B67-42E4-BAC9-1D3F2D8A", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1371545629", oauth_version="1.0", oauth_token="74944468-tYmMuxMaaZUxiTHuZ78Y9qljCqCiPcfKvhavS9wuU", oauth_signature="6E1ggIZYIBrRQJ9i1LeqLQBM5fc%3D"" -H "Accept-Language: en, fr, de, ja, nl, it, es, pt, pt-PT, da, fi, nb, sv, ko, zh-Hans, zh-Hant, ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, en-GB, ca, hu, vi, en-us" "https://api.twitter/1.1/search/tweets.json?q=%23demeern"
如果有人能帮助我,那就太好了.
If somebody could help me it would be great.
推荐答案
允许你在没有用户身份验证的情况下获取搜索结果的 API 是 1.0 版并且它是显示出来的,所以你需要用一些 twitter 库来验证你的请求,这个 <一个 href="https://stackoverflow/questions/17207317/ios-how-to-fetch-tweet-from-twitter-api-1-1/17207745#17207745">链接 将指导你如何这样做以及如何获得搜索结果.
The API which allow you to get search results without user authentication is Version 1.0 and it's displayed, so you need to authenticate your request with some twitter library, this link will guide you how to do that and how to get a search result.
这篇关于无需用户身份验证即可获取搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论