Show
Ignore:
Timestamp:
12/12/07 02:51:09 (13 months ago)
Author:
mootoh
Message:

platform/quicksilver/TwitterPlugin: now it can update Twitter status by HTTP POST method via NSURLConnection.

Location:
platform/quicksilver/TwitterPlugin
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • platform/quicksilver/TwitterPlugin/Info.plist

    r3070 r3071  
    1616        <string>BNDL</string> 
    1717        <key>CFBundleVersion</key> 
    18         <string>27</string> 
     18        <string>38</string> 
    1919        <key>NSPrincipalClass</key> 
    2020        <string>TwitterPlugin</string> 
  • platform/quicksilver/TwitterPlugin/TwitterPluginAction.h

    r3068 r3071  
    1515@interface TwitterPluginAction : QSActionProvider 
    1616{ 
    17   NSData *receivedData; 
     17  id receivedData; 
    1818} 
    1919@end 
  • platform/quicksilver/TwitterPlugin/TwitterPluginAction.m

    r3070 r3071  
    1919 
    2020 
    21   NSString *content = @"post from Cocoa NSURLRequest."; 
     21  NSString *content = @"status=post_from_Cocoa_NSURLRequest."; 
    2222  NSURL *url = [NSURL URLWithString:@"http://user:pass@twitter.com/statuses/update.json"]; 
    2323  NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url]; 
     
    2525  [urlRequest setHTTPBody:[content dataUsingEncoding:NSASCIIStringEncoding]]; 
    2626 
    27   NSLog(@"before"); 
    28  
    29 /* 
    30   // create the request 
    31   NSURLRequest *theRequest=[NSURLRequest 
    32     requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"] 
    33     cachePolicy:NSURLRequestUseProtocolCachePolicy 
    34     timeoutInterval:60.0]; 
    35   // create the connection with the request 
    36   // and start loading the data 
    37 */ 
    3827  NSURLConnection *theConnection = [NSURLConnection 
    3928    connectionWithRequest:urlRequest 
    4029    delegate:self]; 
    4130  if (theConnection) { 
    42     // Create the NSMutableData that will hold 
    43     // the received data 
    44     // receivedData is declared as a method instance elsewhere 
    4531    receivedData = [[NSMutableData data] retain]; 
    4632    NSLog(@"connected !"); 
    4733  } else { 
    4834    NSLog(@"not connected correctly."); 
    49     // inform the user that the download could not be made 
    5035  } 
    5136 
     
    6045  NSLog([dicHead objectForKey:@"Status"]); 
    6146  NSLog(@"didReceiveResponse 2"); 
    62   //abort(); 
     47  [receivedData setLength:0]; 
    6348} 
    6449 
     50- (void) connection : (NSURLConnection *) connection 
     51         didReceiveData : (NSData *) data { 
     52  NSLog(@"didReceiveData 1 %d", [data length]); 
     53   
     54  [receivedData appendData:data]; 
     55 
     56  NSLog(@"didReceiveData 2"); 
     57} 
     58 
     59 - (void) connection : (NSURLConnection *) connection  
     60        didFailWithError : (NSError *) error { 
     61        NSLog(@"didFailWithError 1"); 
     62        // [connection release]; 
     63        // [receivedData release]; 
     64         
     65        NSLog(@"didFailWithError 2"); 
     66} 
     67 
     68- (void) connectionDidFinishLoading:(NSURLConnection *)connection { 
     69        NSLog(@"connectionDidFinishLoading: succeeded to load %d bytes", [receivedData length]); 
     70        [(NSData *)receivedData writeToFile:@"/tmp/connectionDidFinishLoading.log" 
     71                atomically:YES]; 
     72//      [connection release]; 
     73//      [receivedData release]; 
     74} 
    6575@end