Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This would be an updated version using SLRequest instead of TWRequest, which was deprecated in iOS 6. Note this needs the Social and Accounts framework to be added to your project... </p> <pre><code>- (void) postToTwitterInBackground { // Create an account store object. ACAccountStore *accountStore = [[ACAccountStore alloc] init]; // Create an account type that ensures Twitter accounts are retrieved. ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; // Request access from the user to use their Twitter accounts. [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) { if(granted) { // Get the list of Twitter accounts. NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; if ([accountsArray count] &gt; 0) { // Grab the initial Twitter account to tweet from. ACAccount *twitterAccount = [accountsArray objectAtIndex:0]; SLRequest *postRequest = nil; // Post Text NSDictionary *message = @{@"status": @"Tweeting from my iOS app!"}; // URL NSURL *requestURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"]; // Request postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:requestURL parameters:message]; // Set Account postRequest.account = twitterAccount; // Post [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { NSLog(@"Twitter HTTP response: %i", [urlResponse statusCode]); }]; } } }]; } </code></pre>
    singulars
    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. This table or related slice is empty.
    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