我在Xcode项目中设置了TwitterKit。我使用Objective C,我可以通过ID成功访问Tweets,并查询REST API。但是我想使用Streaming API并且文档没有说清楚我是否可以进行Streaming,比如说包含单词" space"的推文。
使用下面的代码我永远不会得到一个响应对象。任何帮助都将非常感激:
NSString *statusesShowEndpoint = @"https://stream.twitter.com/1.1/statuses/sample.json";
NSDictionary *params = @{};
NSError *clientError;
NSURLRequest *request = [[[Twitter sharedInstance] APIClient]
URLRequestWithMethod:@"POST"
URL:statusesShowEndpoint
parameters:params
error:&clientError];
if (request) {
[[[Twitter sharedInstance] APIClient]
sendTwitterRequest:request
completion:^(NSURLResponse *response,
NSData *data,
NSError *connectionError) {
NSLog(@"response0 %@", response);
if (data) {
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:data
options:0
error:&jsonError];
NSLog(@"json %@", json);
NSLog(@"response1 %@", response);
}
else {
NSLog(@"Error1: %@", connectionError);
NSLog(@"response2 %@", response);
}
}];
}
else {
NSLog(@"Error: %@", clientError);
}