Share plain text on twitter

I am working on sharing features and want to share plain text on Twitter. I know that we use the Compose and Account Twitter features that are registered in the settings. I found a pattern that shares media, but I don't have media: just plain text. Can someone help me find the request url needed to share plain text?

UIImage *image = [UIImage imageNamed:@"shareit.png"]; NSData *imageData = UIImageJPEGRepresentation(image, 0.7); NSString *statusesShowEndpoint = @"https://upload.twitter.com/1.1/media/upload.json"; // (This url is used to share media, but I want text rather than an image.) NSDictionary *params = @{@"media" : imageData}; // **** (Don't know the parameter for share text) NSError *clientError; NSURLRequest *request = [[[Twitter sharedInstance] APIClient] URLRequestWithMethod:@"POST" URL:statusesShowEndpoint parameters:params error:&clientError]; if (request) { [[[Twitter sharedInstance] APIClient] sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) { if (data) { // handle the response data eg NSError *jsonError; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; NSLog(@"%@",json); } else { NSLog(@"Error: %@", connectionError); } }]; } else { NSLog(@"Error: %@", clientError); } 

I want two things:

  • Request URL
  • exchange option
+4
source share
1 answer

First, load the FHSTwitterEngine class

after the verification user is registered on Twitter or not, if the user has not registered, then ask about the login. on the tweet button.

 -(IBAction)tweet:(id)sender { if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"SavedAccessHTTPBody"] length] > 0) { [self TwitterStatus]; } else { UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) { if (success) { NSLog(@"== %@",[[NSUserDefaults standardUserDefaults] objectForKey:@"SavedAccessHTTPBody"]); [self TwitterStatus]; } NSLog( success?@ "L0L success":@"O noes!!! Loggen faylur!!!"); // NSLog(@"Sucess = %d",[success integervalue]); }]; [self presentViewController:loginController animated:YES completion:nil]; } } 

Now, if the user is already logged in, then TwitterStatus is called and tweet in your account, as shown below.

 -(void)TwitterStatus { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ @autoreleasepool { NSString *tweet = @"This is testing message with image."; NSData *data=UIImagePNGRepresentation([UIImage imageNamed:@"scan.png"]); NSError *returned = [[FHSTwitterEngine sharedEngine]postTweet:tweet withImageData:data]; NSLog(@"== %@",returned); [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; NSString *title = nil; NSString *message = nil; if ([returned isKindOfClass:[NSError class]]) { NSError *error = (NSError *)returned; title = [NSString stringWithFormat:@"Error %ld",(long)error.code]; message = error.localizedDescription; } else { NSLog(@"%@",returned); title = @"Tweet Posted"; message = tweet; } dispatch_sync(dispatch_get_main_queue(), ^{ @autoreleasepool { UIAlertView *av = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [av show]; } }); } }); } 

You can also answer, love and relearn Refer

+1
source

All Articles