TWRequest is deprecated in iOS 6.0 - what can I use instead? TWRequest is deprecated in iOS 6.0 - what can I use instead? ios ios

TWRequest is deprecated in iOS 6.0 - what can I use instead?


On iOS 6 you should use the Social.framework. This has a class named SLRequest.

You use it almost in the same way as the deprecated TWRequest, but you need to specify that it's a twitter request as opposed to a facebook request.

The entire Twitter.framework became deprecated as of iOS 6, since Apple added Facebook and Weibo (a Chinese social network) to iOS 6, they grouped all social classes into the new Social.framework.

Note you must specify the service type for Twitter/Facebook, Example:

SLRequest *aRequest  = [SLRequest requestForServiceType:SLServiceTypeTwitter                                          requestMethod:SLRequestMethodPOST                                                    URL:myurl                                             parameters:myparams];

Be sure to check out the documentation.


Here is a complete code to upload text + image to your Twitter Account using Twitter api

    UIImage *img = [UIImage imageNamed:@"twitterImage.png"];    ACAccountStore *account = [[ACAccountStore alloc] init];    ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];    [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {        if (granted == YES) {            // Populate array with all available Twitter accounts            NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];            if ([arrayOfAccounts count] > 0) {                ACAccount *acct = [arrayOfAccounts objectAtIndex:0];                NSDictionary *message = @{@"status": @"From my app"};                NSURL *requestURL = [NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"];                SLRequest *postRequest = [SLRequest                                                  requestForServiceType:SLServiceTypeTwitter                                                  requestMethod:SLRequestMethodPOST                                                  URL:requestURL parameters:message];                NSData *data = UIImagePNGRepresentation(img);                [postRequest addMultipartData:data withName:@"media" type:@"image/png" filename:@"TestImage"];                postRequest.account = acct;                [postRequest performRequestWithHandler:                     ^(NSData *responseData, NSHTTPURLResponse                       *urlResponse, NSError *error)                     {                         if (error) {                             NSLog(@"%@",error.description);                         }                         else {                             NSLog(@"Upload Sucess !");                         }                     }];            }        }    }];


In case you plan on integrating TwitterKit by Twitter to perform the tweets via your custom twitter app then this might help you.

https://stackoverflow.com/a/28602749/1740354