-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathmain.m
70 lines (46 loc) · 2.06 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
64
65
66
67
68
69
70
//
// 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 {
NSString * const TWITTER_CONSUMER_KEY = @"";
NSString * const TWITTER_CONSUMER_SECRET_KEY = @"";
if ([TWITTER_CONSUMER_KEY length] == 0) {
NSLog(@"You need to set a Consumer Key.");
exit(1);
}
if ([TWITTER_CONSUMER_SECRET_KEY length] == 0) {
NSLog(@"You need to set a Consumer Seacret Key.");
exit(1);
}
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil consumerKey:TWITTER_CONSUMER_KEY consumerSecret:TWITTER_CONSUMER_SECRET_KEY];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader successBlock:^(NSString *oAuthToken, NSString *oAuthTokenSecret, NSString *userID, NSString *screenName) {
NSLog(@"REVERSE AUTH OK");
exit(0);
} errorBlock:^(NSError *error) {
NSLog(@"ERROR, %@", [error localizedDescription]);
exit(1);
}];
} errorBlock:^(NSError *error) {
NSLog(@"ERROR");
exit(1);
}];
} errorBlock:^(NSError *error) {
NSLog(@"ERROR");
exit(1);
}];
/**/
[[NSRunLoop currentRunLoop] run];
}
return 0;
}