无需用户身份验证即可获取搜索结果

编程入门 行业动态 更新时间:2024-10-25 15:32:28
本文介绍了无需用户身份验证即可获取搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-29 15:34:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1192077.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:搜索结果   身份验证   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!