Permalink
Browse files

Added method post with upload photo

  • Loading branch information...
lucascorrea committed Mar 26, 2012
1 parent 4ac83b5 commit feed19e88f650f2f4a9e105fdc7d138086794307
@@ -61,5 +61,7 @@ typedef void(^SCTwitterDirectCallback)(BOOL success, id result);
+ (void)getUserInformationFor:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
+ (void)directMessage:(NSString *)message to:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
+ (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id result))aCallback;
++ (void)postWithMessage:(NSString *)message uploadPhoto:(UIImage *)image callback:(void (^)(BOOL success, id result))aCallback;
++ (void)postWithMessage:(NSString *)message uploadPhoto:(UIImage *)image latitude:(double)lat longitude:(double)lng callback:(void (^)(BOOL success, id result))aCallback;
@end
@@ -28,6 +28,7 @@
@interface SCTwitter()
+- (BOOL)isSessionValid;
- (void)loginViewControler:(UIViewController *)aViewController callback:(void (^)(BOOL success))aCallback;
- (void)logoutCallback:(void (^)(BOOL success))aCallback;
- (void)postWithMessage:(NSString *)message callback:(void (^)(BOOL success, id result))aCallback;
@@ -36,7 +37,7 @@ - (void)getUserTimelineFor:(NSString *)username sinceID:(unsigned long)sinceID s
- (void)getUserInformationFor:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
- (void)directMessage:(NSString *)message to:(NSString *)username callback:(void (^)(BOOL success, id result))aCallback;
- (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id result))aCallback;
-- (BOOL)isSessionValid;
+- (void)postWithMessage:(NSString *)message uploadPhoto:(UIImage *)image latitude:(double)lat longitude:(double)lng callback:(void (^)(BOOL success, id result))aCallback;
@end
@@ -49,6 +50,8 @@ @implementation SCTwitter
@synthesize userCallback;
@synthesize directCallback;
+
+
#pragma mark -
#pragma mark Singleton
@@ -138,6 +141,18 @@ + (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id
[[SCTwitter shared] retweetMessage:updateID callback:aCallback];
}
++ (void)postWithMessage:(NSString *)message uploadPhoto:(UIImage *)image callback:(void (^)(BOOL success, id result))aCallback
+{
+ [[SCTwitter shared] postWithMessage:message uploadPhoto:image latitude:0 longitude:0 callback:aCallback];
+}
+
++ (void)postWithMessage:(NSString *)message uploadPhoto:(UIImage *)image latitude:(double)lat longitude:(double)lng callback:(void (^)(BOOL success, id result))aCallback
+{
+ [[SCTwitter shared] postWithMessage:message uploadPhoto:image latitude:lat longitude:lng callback:aCallback];
+}
+
+
+
#pragma mark -
#pragma mark Private Methods
@@ -288,6 +303,25 @@ - (void)retweetMessage:(NSString *)updateID callback:(void (^)(BOOL success, id
}
}
+- (void)postWithMessage:(NSString *)message uploadPhoto:(UIImage *)image latitude:(double)lat longitude:(double)lng callback:(void (^)(BOOL success, id result))aCallback
+{
+ if (![self isSessionValid]) {
+
+ // Call the login callback if we have one
+ if (aCallback) {
+ aCallback(NO, @"Error");
+ }
+
+ }else{
+
+ self.statusCallback = aCallback;
+ [_engine sendUpdate:message uploadPhoto:image latitude:lat longitude:lng];
+ }
+}
+
+
+
+
#pragma mark -
#pragma mark - SA_OAuthTwitterControllerDelegate methods
@@ -70,6 +70,8 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return NO;
}
+
+
#pragma mark - Button Action
- (IBAction)loginButtonAction:(id)sender
@@ -146,7 +148,7 @@ - (IBAction)directMessageButtonAction:(id)sender
loadingView.hidden = NO;
[SCTwitter directMessage:messageText.text to:nil callback:^(BOOL success, id result) {
-
+
loadingView.hidden = YES;
if (success) {
//Return array NSDictonary
@@ -169,7 +171,7 @@ - (IBAction)retweetButtonAction:(id)sender
NSLog(@"%@", result);
}
}];
-
+
}
#pragma mark -

0 comments on commit feed19e

Please sign in to comment.