Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>*<em>*</em>@charanjit i have write a code for that by which u can post text on tumbler try this code:-</p> <pre><code>@interface NSString (MIMEAdditions) + (NSString*)MIMEBoundary; + (NSString*)multipartMIMEStringWithDictionary:(NSDictionary*)dict; @end @implementation NSString (MIMEAdditions) //this returns a unique boundary which is used in constructing the multipart MIME body of the POST request + (NSString*)MIMEBoundary { static NSString* MIMEBoundary = nil; if(!MIMEBoundary) MIMEBoundary = [[NSString alloc] initWithFormat:@"----_=TheRealTester%@_=_----",[[NSProcessInfo processInfo] globallyUniqueString]]; return MIMEBoundary; } //this create a correctly structured multipart MIME body for the POST request from a dictionary + (NSString*)multipartMIMEStringWithDictionary:(NSDictionary*)dict { NSMutableString* result = [NSMutableString string]; for (NSString* key in dict) { [result appendFormat:@"--%@\nContent-Disposition: form-data; name=\"%@\"\n\n%@\n",[NSString MIMEBoundary],key,[dict objectForKey:key]]; } [result appendFormat:@"\n--%@--\n",[NSString MIMEBoundary]]; return result; } @end </code></pre> <p>**above code for write in .m file before implementation . after that write this code..</p> <pre><code>- (IBAction)postToTumblr1 { NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; BOOL b = [emailTest evaluateWithObject:emailtext.text]; if (b==NO) { UIAlertView *messageBox = [[UIAlertView alloc]initWithTitle:@" " message:@"Invalid Email ID" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [messageBox show]; [messageBox release]; } else { NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://www.tumblr.com/api/write"]]; [request setHTTPMethod:@"POST"]; //tell the server to expect 8-bit encoded content as we're sending UTF-8 data, and UTF-8 is an 8-bit encoding [request addValue:@"8bit" forHTTPHeaderField:@"Content-Transfer-Encoding"]; //set the content-type header to multipart MIME [request addValue: [NSString stringWithFormat:@"multipart/form-data; boundary=%@",[NSString MIMEBoundary]] forHTTPHeaderField: @"Content-Type"]; //create a dictionary for all the fields you want to send in the POST request NSDictionary* postData = [NSDictionary dictionaryWithObjectsAndKeys: emailtext.text, @"email", password.text, @"password", @"regular", @"type", @"The Real Compatibility Tester", @"title", postText, @"body", nil]; //set the body of the POST request to the multipart MIME encoded dictionary [request setHTTPBody: [[NSString multipartMIMEStringWithDictionary: postData] dataUsingEncoding: NSUTF8StringEncoding]]; NSLog(@"Tumblr Login:%@\nTumblr ", emailtext.text); [NSURLConnection connectionWithRequest:request delegate:self]; [request release]; yes=1; if(1) { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Tumblr Post" message:@"Post successfully" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil]; [alert show]; [alert release]; } else { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Tumblr Post" message:@"Post not successfully done" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil]; [alert show]; [alert release]; } } } - (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { // the user clicked one of the OK/Cancel buttons if (buttonIndex == 0) { [self dismissModalViewControllerAnimated:YES]; } else { NSLog(@"cancel"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload