gpt4 book ai didi

ios - 使用适用于 iOS 的 twitter 框架进行搜索

转载 作者:行者123 更新时间:2023-11-29 02:40:37 26 4
gpt4 key购买 nike

我不明白如何使用 iOS 中包含的 twitter 框架进行搜索...有人可以发布示例吗?谢谢

最佳答案

您可以轻松地使用 TWRequest 类来创建具有正确 URL 的请求。

查看详细的文档类(class): https://developer.apple.com/library/ios/documentation/Twitter/Reference/TWRequestClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40010942

要了解如何创建 Twitter 请求,我建议您阅读以下教程: http://iosdevelopertips.com/core-services/ios-5-twitter-framework-part-2.html

这段代码来自上面的教程,作者以搜索为例:

#import <Twitter/Twitter.h>

...

// Do a simple search, using the Twitter API
TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:
@"http://search.twitter.com/search.json?q=iOS%205&rpp=5&with_twitter_user_id=true&result_type=recent"]
parameters:nil requestMethod:TWRequestMethodGET];

// Notice this is a block, it is the handler to process the response
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if ([urlResponse statusCode] == 200)
{
// The response from Twitter is in JSON format
// Move the response into a dictionary and print
NSError *error;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
NSLog(@"Twitter response: %@", dict);
}
else
NSLog(@"Twitter error, HTTP response: %i", [urlResponse statusCode]);
}];

详细的API信息可以查看Twitter API documentation .

关于ios - 使用适用于 iOS 的 twitter 框架进行搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25851812/

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