Search Results

Search found 4 results on 1 pages for 'timothy5216'.

Page 1/1 | 1 

  • How do I upload an NSImage(NSData)to Twitpic with OAMutableURLRequest?

    - by timothy5216
    I'm using OAConsumer in my xAuth twitterEngine and i'm adding Twitpic OAuth Echo to it. But it won't POST the NSData. here is some of my code: //other file NSArray *reps = [[imageToUpload image] representations]; NSData *imageData = [NSBitmapImageRep representationOfImageRepsInArray:reps usingType:NSJPEGFileType properties:nil]; [twitter testUploadImageData:imageData withMessage:@"Hello WORLD!!" toURL:[NSURL URLWithString:uploadURL.stringValue]]; // - (void)testUploadImageData:(NSData *)data withMessage:(NSString *)message toURL:(NSURL *)url; { //url = @"http://api.twitpic.com/2/upload.xml" //message = @"Hello WORLD!!" NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *String = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSLog(@"dataString: %@",String); OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url consumer:self.consumer token:_accessToken realm:nil signatureProvider:nil]; // Setup POST body [request setHTTPMethod:@"POST"]; //NSString *stringBoundary = [NSString stringWithString:@"0xKhTmLbOuNdArY"]; //NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", stringBoundary]; // NSString *stringBoundarySeparator = [NSString stringWithFormat:@"\r\n--%@\r\n", stringBoundary]; /* NSMutableString *postString = [NSMutableString string]; [postString appendString:@"\r\n"]; [postString appendString:stringBoundarySeparator]; [postString appendString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"message\"\r\n\r\n%@", message]]; [postString appendString:stringBoundarySeparator]; [postString appendString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"media\"; filename=\"%@\"\r\n", @"file.jpg"]]; [postString appendString:@"Content-Type: image/jpg\r\n"]; [postString appendString:@"Content-Transfer-Encoding: binary\r\n\r\n"]; // Setting up the POST request's multipart/form-data body NSMutableData *postBody = [NSMutableData data]; [postBody appendData:[postString dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:data]; [request setHTTPBody:postBody]; */ [request setHTTPMethod:@"POST"]; NSString *thing = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSLog(@"%@",thing); [request setParameters:[NSArray arrayWithObjects: [OARequestParameter requestParameterWithName:@"oauth_token" value:_accessToken.key], [OARequestParameter requestParameterWithName:@"X-Auth-Service-Provider" value:@"https://api.twitter.com/1/account/verify_credentials.json"], [OARequestParameter requestParameterWithName:@"key" value:@"my-key-here :P"], [OARequestParameter requestParameterWithName:@"message" value:message], //iv'e changed this many times. I was just trying this to see if it works [OARequestParameter requestParameterWithName:@"media" value:thing], nil]]; OAAsynchronousDataFetcher *dataFetcher = [[OAAsynchronousDataFetcher alloc] init]; [dataFetcher initWithRequest:request delegate:self didFinishSelector:@selector(uploadDidUpload:withData:) didFailSelector:@selector(uploadDidFail:withData:)]; [dataFetcher start]; [dataFetcher release]; [request release]; [pool drain]; } I'm authenticated but it still won't POST the data :(

    Read the article

  • Trying to parse twitter trends

    - by timothy5216
    Im trying to parse twitter trends but i keep getting a parser error at "as_of". anyone know why this is happening? EDIT: Here is the code im using NSMutableArray *tweets; tweets = [[NSMutableArray alloc] init]; NSURL *url = [NSURL URLWithString:@"http://search.twitter.com/trends/current.json"]; trendsArray = [[NSMutableArray alloc] initWithArray:[CCJSONParser objectFromJSON:[NSString stringWithContentsOfURL:url encoding:4 error:nil]]]; NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; for (int i = 0; i < [trendsArray count]; i++) { dict = [[NSMutableDictionary alloc] init]; //[post setObject: [[currentArray objectAtIndex:i] objectForKey:@"query"]]; [dict setObject:[trendsArray objectAtIndex:i] forKey:@"trends"]; //[dict setObject:[trendsArray objectAtIndex:i] forKey:@"query"]; //[post setObject:[trendsArray objectAtIndex:i] forKey:@"as_of"]; [tweets addObject:dict]; //post = nil; }

    Read the article

  • How do I make a custom delegate protocol for a UIView subclass?

    - by timothy5216
    I'm making some tabs and I want to have my own delegate for them but when I try to send an action to the delegate nothing happens. I also tried following this tutorial: link text But it doesn't work for me :( Here is my code: TiMTabBar.h @protocol TiMTabBarDelegate; @interface TiMTabBar : UIView { id<TiMTabBarDelegate> __delegate; ... int selectedItem; ... } //- (id)init; - (id)initWithDelegate:(id)aDelegate; - (void)setSelectedIndex:(int)item; .. @property (nonatomic) int selectedItem; @property(assign) id <TiMTabBarDelegate> __delegate; .. ... @end @protocol TiMTabBarDelegate<NSObject> //@optional - (void)tabBar:(TiMTabBar *)_tabBar didSelectIndex:(int)index; @end TiMTabBar.m: #import "TiMTabBar.h" ... @interface NSObject (TiMTabBarDelegate) - (void)tabBar:(TiMTabBar *)_tabBar didSelectIndex:(int)index; @end @implementation TiMTabBar @synthesize selectedItem; @synthesize __delegate; ... /* - (id)init { ... return self; } */ - (id)initWithDelegate:(id)aDelegate; { //[super init]; __delegate = aDelegate; return self; } - (void)awakeFromNib { //[self init]; //[self initWithDelegate:self]; ... } - (void)setSelectedIndex:(int)item { selectedItem = item; if (self.__delegate != NULL && [self.__delegate respondsToSelector:@selector(tabBar:didSelectIndex:)]) { [__delegate tabBar:self didSelectIndex:selectedItem]; } ... if (item == 0) { ... } else if (item == 1) { ... } else if (item == 2) { ... } else if (item == 3) { ... } else if (item == 4) { ... } else { ... } } /* - (void)tabBar:(TiMTabBar *)_tabBar didSelectIndex:(int)index; { //[delegate tabBar:self didSelectIndex:index]; //if (self.delegate != NULL && [self.delegate respondsToSelector:@selector(tabBar:didSelectIndex:)]) { //[delegate tabBar:self didSelectIndex:selectedItem]; //} NSLog(@"tabBarDelegate: %d",index); } */ @end The delegate only works works inside itself and not in any other files like: @interface XXXController : UIViewController <TiMTabBarDelegate> { ... ... IBOutlet TiMTabBar *tabBar; ... } ... @end XXXController.m: #import "XXXController.h" #import <QuartzCore/QuartzCore.h> @implementation XXXController - (void)viewDidLoad { [super viewDidLoad]; [self becomeFirstResponder]; ... tabBar = [[TiMTabBar alloc] initWithDelegate:self]; //tabBar.__delegate = self; ... } #pragma mark TiMTabBar Stuff - (void)tabBar:(TiMTabBar *)_tabBar didSelectIndex:(int)index; { NSLog(@"Controller/tabBarDelegate: %d",index); } @end None of this seems to work in XXXController. Anyone know how to make this work?

    Read the article

1