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

platform/quicksilver/TwitterPlugin: add HTTP POST skelton.

Location:
platform/quicksilver/TwitterPlugin
Files:
3 modified

Legend:

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

    r3066 r3068  
    1616        <string>BNDL</string> 
    1717        <key>CFBundleVersion</key> 
    18         <string>1F</string> 
     18        <string>23</string> 
    1919        <key>NSPrincipalClass</key> 
    2020        <string>TwitterPlugin</string> 
  • platform/quicksilver/TwitterPlugin/TwitterPluginAction.h

    r3067 r3068  
    1515@interface TwitterPluginAction : QSActionProvider 
    1616{ 
     17  NSData *receivedData; 
    1718} 
    1819@end 
  • platform/quicksilver/TwitterPlugin/TwitterPluginAction.m

    r3067 r3068  
    1212 
    1313- (QSObject *)performActionOnObject:(QSObject *)dObject{ 
    14         return nil; 
     14  QSObject *result; 
     15  NSString *dWithHello; 
     16 
     17  dWithHello = [NSString stringWithFormat:@"%@ hello",[dObject stringValue]]; 
     18  result = [QSObject objectWithString:dWithHello]; 
     19 
     20 
     21  NSString *content = @"post from Cocoa NSURLRequest."; 
     22  NSURL *url = [NSURL URLWithString:@"http://user:pass@twitter.com/statuses/update.json"]; 
     23  NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url]; 
     24  [urlRequest setHTTPMethod:@"POST"]; 
     25  [urlRequest setHTTPBody:[content dataUsingEncoding:NSASCIIStringEncoding]]; 
     26 
     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*/ 
     38  NSURLConnection *theConnection = [NSURLConnection 
     39    connectionWithRequest:urlRequest 
     40    delegate:self]; 
     41  if (theConnection) { 
     42    // Create the NSMutableData that will hold 
     43    // the received data 
     44    // receivedData is declared as a method instance elsewhere 
     45    receivedData = [[NSMutableData data] retain]; 
     46    NSLog(@"connected !"); 
     47  } else { 
     48    NSLog(@"not connected correctly."); 
     49    // inform the user that the download could not be made 
     50  } 
     51 
     52  return result; 
    1553} 
     54 
     55- (void) connection : (NSURLConnection *) connection 
     56         didReceiveResponse : (NSURLResponse *) response { 
     57  NSLog(@"didReceiveResponse 1"); 
     58 
     59  NSDictionary *dicHead = [(NSHTTPURLResponse *)response allHeaderFields]; 
     60  NSLog([dicHead objectForKey:@"Last-Modified"]); 
     61  //NSLog(@"didReceiveResponse 2"); 
     62  //abort(); 
     63} 
     64 
    1665@end