使用iOS的twitter框架进行搜索
我不明白如何使用iOS中的twitter框架进行搜索。。。 有人能举个例子吗?使用iOS的twitter框架进行搜索,ios,objective-c,twitter,Ios,Objective C,Twitter,我不明白如何使用iOS中的twitter框架进行搜索。。。 有人能举个例子吗? 谢谢您可以轻松使用TWRequest类创建具有正确URL的请求 参见课程的详细文档: 要了解如何创建Twitter请求,我建议您阅读以下教程: 此代码来自上面的教程,作者以搜索为例: #import <Twitter/Twitter.h> ... // Do a simple search, using the Twitter API TWRequest *request = [[TWReques
谢谢您可以轻松使用
TWRequest
类创建具有正确URL的请求
参见课程的详细文档:
要了解如何创建Twitter请求,我建议您阅读以下教程:
此代码来自上面的教程,作者以搜索为例:
#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]);
}];
#导入
...
//使用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"]
参数:nil requestMethod:TWRequestMethodGET];
//请注意,这是一个块,它是处理响应的处理程序
[请求性能请求处理程序:^(NSData*responseData,NSHTTPURLRResponse*urlResponse,NSError*error)
{
如果([urlResponse statusCode]==200)
{
//Twitter的响应是JSON格式的
//将响应移动到字典中并打印
n错误*错误;
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:responseData选项:0错误:&错误];
NSLog(@“推特响应:%@”,dict);
}
其他的
NSLog(@“Twitter错误,HTTP响应:%i”,[urlResponse statusCode]);
}];
有关详细的API信息,您可以查看