-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathmain.m
55 lines (41 loc) · 2.09 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
//
// main.m
// streaming
//
// Created by Nicolas Seriot on 02/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 {
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitter verifyCredentialsWithUserSuccessBlock:^(NSString *username, NSString *userID) {
NSLog(@"-- Account: %@", username);
[twitter postStatusesFilterUserIDs:nil
keywordsToTrack:@[@"Apple"]
locationBoundingBoxes:nil
stallWarnings:nil
progressBlock:^(NSDictionary *json, STTwitterStreamJSONType type) {
if (type != STTwitterStreamJSONTypeTweet) {
NSLog(@"Invalid tweet (class %@): %@", [json class], json);
exit(1);
return;
}
printf("-----------------------------------------------------------------\n");
printf("-- user: @%s\n", [[json valueForKeyPath:@"user.screen_name"] cStringUsingEncoding:NSUTF8StringEncoding]);
printf("-- text: %s\n", [[json objectForKey:@"text"] cStringUsingEncoding:NSUTF8StringEncoding]);
} errorBlock:^(NSError *error) {
NSLog(@"Stream error: %@", error);
exit(1);
}];
} errorBlock:^(NSError *error) {
NSLog(@"-- %@", [error localizedDescription]);
exit(1);
}];
/**/
[[NSRunLoop currentRunLoop] run];
}
return 0;
}