Skip to content
Newer
Older
100644 121 lines (99 sloc) 3.59 KB
7327929 connection singleton
Joe authored
1 //
2 // SpacesTwitterConnection.m
3 // SPACES
4 //
7cbfc08 new challenge table
Joe authored
5 // Created by Joe Cannatti, Troy Sartain on 7/16/10.
7327929 connection singleton
Joe authored
6 // Copyright 2010 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "SpacesTwitterConnection.h"
8eca433 @joecannatti add get all spaces method
authored
10 #import "NSString+UUID.h"
da5860d updates to photo posting
Randy Beiter authored
11 #import "ASIFormDataRequest.h"
12 #import "ASIHTTPRequest.h"
7327929 connection singleton
Joe authored
13
14 @implementation SpacesTwitterConnection
44275b8 @joecannatti Begin Refactoring Singleton
authored
15 @synthesize twitter;
7327929 connection singleton
Joe authored
16
9e39e3a @joecannatti finish singlton refactor
authored
17 -(id) initWithDelegate:(id)_delegate
7327929 connection singleton
Joe authored
18 {
44275b8 @joecannatti Begin Refactoring Singleton
authored
19 if (self = [super init]) {
93b1cc8 hacking away at twitter submission
Randy Beiter authored
20 self.twitter = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:_delegate];
21 // [self.twitter setConsumerKey:@"9iERUaqhjAUG2kHKLGPZ8g" secret:@"h7k1zcHCwGMHD7UeF1vQmETpog9ce2bneNsyM3q60Ko"];
22 twitter.consumerKey = @"9iERUaqhjAUG2kHKLGPZ8g";
23 twitter.consumerSecret = @"h7k1zcHCwGMHD7UeF1vQmETpog9ce2bneNsyM3q60Ko";
44275b8 @joecannatti Begin Refactoring Singleton
authored
24 return self;
25 }
26 else {
27 return nil;
9e39e3a @joecannatti finish singlton refactor
authored
28 }
7327929 connection singleton
Joe authored
29 }
30
9e39e3a @joecannatti finish singlton refactor
authored
31 -(void)setUsername:(NSString*)username andPassword:(NSString*)password{
32 [twitter setUsername:username password:password];
83a408e @joecannatti Split Twitter engine creation into two methods
authored
33 }
34
bc13183 @joecannatti Follow on twitter button
authored
35 -(void)followSPACES{
36 [twitter enableUpdatesFor:@"spacesgallery"];
37 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"You are now following SPACES" message:@"Nice to meet you." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
38 [alert show];
39 }
40
9e39e3a @joecannatti finish singlton refactor
authored
41 -(NSString*)getAllSpacesTweets
d790370 upload method tested and it works
Joe authored
42 {
6d6360f new pink icon, black gradient
Joe authored
43 NSString *ret = [twitter getUserTimelineFor:@"spacesgallery" sinceID:0 startingAtPage:0 count:20];
44 NSLog(ret,nil);
45 return ret;
46 }
47
48 -(NSString*)getSomeSpacesTweets: (int) cnt
49 {
50 NSString *ret = [twitter getUserTimelineFor:@"spacesgallery" sinceID:0 startingAtPage:0 count:cnt];
b1e05b6 @joecannatti callbacks for twitter request
authored
51 NSLog(ret,nil);
7cbfc08 new challenge table
Joe authored
52 return ret;
53 }
54
9e39e3a @joecannatti finish singlton refactor
authored
55 -(NSString *) getChallengeTweets
7cbfc08 new challenge table
Joe authored
56 {
363dc65 tble views
Joe authored
57 // NSString *url = @"from:spacesgallery+#DailyArtDose";
58 // NSString *ret = [twitter getSearchResultsForQuery:url];
6d6360f new pink icon, black gradient
Joe authored
59 NSString *ret = [twitter getUserTimelineFor:@"spacesgallery" sinceID:0 startingAtPage:0 count:52];
b1e05b6 @joecannatti callbacks for twitter request
authored
60 NSLog(ret,nil);
8eca433 @joecannatti add get all spaces method
authored
61 return ret;
62 }
63
3ad7061 @joecannatti spinner for tweet submit
authored
64 -(void) uploadPicAndPost: (UIImage *)pic andMessage:(NSString *)msg sender:(id)_sender
99f5201 upload pic and post msg method
Joe authored
65 {
66
67 NSData *imageData = UIImageJPEGRepresentation(pic, .90);
68
ed98715 @joecannatti working on twitpic auth
authored
69 NSURLRequest *request = [NSURLRequest requestWithURL:[twitter accessTokenURL]];
70 NSURLResponse *response = nil;
71 NSError *error = nil;
72 NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
73 NSString *accessToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
3ad7061 @joecannatti spinner for tweet submit
authored
74
ed98715 @joecannatti working on twitpic auth
authored
75 NSURL *twitpicURL = [NSURL URLWithString:@"http://api.twitpic.com/2/upload.json"];
99f5201 upload pic and post msg method
Joe authored
76
ed98715 @joecannatti working on twitpic auth
authored
77 // ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:twitpicURL] autorelease];
78 //
79 // [request setData:imageData forKey:@"media"];
80 // [request setPostValue:msg forKey:@"message"];
81 //
82 // [request setDelegate:self];
83 // [request setDidFinishSelector:@selector(requestDone:)];
84 // [request setDidFailSelector:@selector(requestFailed:)];
85 //
86 // [request start];
87 // [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
88 //
89 // accessTokenURL
90
3ad7061 @joecannatti spinner for tweet submit
authored
91 sender = _sender;
99f5201 upload pic and post msg method
Joe authored
92 }
8eca433 @joecannatti add get all spaces method
authored
93
da5860d updates to photo posting
Randy Beiter authored
94 - (void)requestDone:(ASIHTTPRequest *)request {
95 CFShow(request);
74501df Block user interactions while submitting
Randy Beiter authored
96 [[UIApplication sharedApplication] endIgnoringInteractionEvents];
857d56c added alert boxes for success/failure to submit image
Randy Beiter authored
97 if ([sender respondsToSelector:@selector(submissionSuccessful)]) {
98 [sender performSelectorOnMainThread:@selector(submissionSuccessful) withObject:nil waitUntilDone:NO];
99 }
da5860d updates to photo posting
Randy Beiter authored
100 }
101
102 - (void)requestFailed:(ASIHTTPRequest *)request {
103 CFShow(request);
74501df Block user interactions while submitting
Randy Beiter authored
104 [[UIApplication sharedApplication] endIgnoringInteractionEvents];
857d56c added alert boxes for success/failure to submit image
Randy Beiter authored
105 if ([sender respondsToSelector:@selector(submissionFailed)]) {
106 [sender performSelectorOnMainThread:@selector(submissionFailed) withObject:nil waitUntilDone:NO];
107 }
da5860d updates to photo posting
Randy Beiter authored
108 }
83a408e @joecannatti Split Twitter engine creation into two methods
authored
109
44275b8 @joecannatti Begin Refactoring Singleton
authored
110 -(NSString*)getSubmissionsForTag:(NSString*)_tag{
9dc49a9 @joecannatti imageviewer working
authored
111
44275b8 @joecannatti Begin Refactoring Singleton
authored
112 return [twitter getSearchResultsForQuery:_tag];
113 }
114
1f131e9 added twitter credential verification
Michael Wang authored
115 - (NSString *)checkUserCredentials {
116 return [twitter checkUserCredentials];
117 }
118
44275b8 @joecannatti Begin Refactoring Singleton
authored
119
7327929 connection singleton
Joe authored
120 @end
Something went wrong with that request. Please try again.