-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathmain.m
63 lines (48 loc) · 2.81 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// main.m
// streaming
//
// Created by Nicolas Seriot on 03/05/14.
// Copyright (c) 2014 Nicolas Seriot. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "STTwitter.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
__block NSMutableArray *followersIDs = [NSMutableArray array];
STTwitterAPI *t = [STTwitterAPI twitterAPIWithOAuthConsumerKey:@""
consumerSecret:@""
username:@""
password:@""];
[t verifyCredentialsWithUserSuccessBlock:^(NSString *username, NSString *userID) {
[t fetchAndFollowCursorsForResource:@"followers/ids.json"
HTTPMethod:@"GET"
baseURLString:@"https://api.twitter.com/1.1"
parameters:@{@"screen_name":@"0xcharlie"}
uploadProgressBlock:nil
downloadProgressBlock:nil
successBlock:^(id request, NSDictionary *requestHeaders, NSDictionary *responseHeaders, id response, BOOL morePagesToCome, BOOL *stop) {
NSLog(@"-- success, more to come: %d, %@", morePagesToCome, response);
NSArray *ids = [response valueForKey:@"ids"];
if(ids) {
[followersIDs addObjectsFromArray:ids];
NSLog(@"-- added %lu IDs, more to come: %d", [ids count], morePagesToCome);
}
if(morePagesToCome == NO) {
NSLog(@"-- IDs count: %lu", (unsigned long)[followersIDs count]);
NSLog(@"-- IDs: %@", followersIDs);
}
} pauseBlock:^(NSDate *nextRequestDate) {
NSLog(@"-- rate limit exhausted, nextRequestDate: %@", nextRequestDate);
} errorBlock:^(id request, NSDictionary *requestHeaders, NSDictionary *responseHeaders, NSError *error) {
NSLog(@"-- %@", error);
}];
} errorBlock:^(NSError *error) {
NSLog(@"--1 %@", error);
}];
/**/
[[NSRunLoop currentRunLoop] run];
}
return 0;
}