objective-ctwitterslrequest

how to deactivate twitter account in iPhone app that used for Integration


I have app where I am doing the Twitter integration.

I am able to successfully tweets.

Now when I want to de-activate, I am using below.

SLRequest *postRequest1 = [SLRequest requestForServiceType:SLServiceTypeTwitter 
requestMethod:SLRequestMethodPOST URL:
[NSURL URLWithString:@"https://api.twitter.com/1/account/end_session.json"] 
parameters: [NSDictionary dictionaryWithObject:@"" forKey:@"status"]];

Problem is API with 1 is deprecated and I don't find this method in 1.1.

Is there any alternate for this?

Also what I notice is when I try to activate again, the permission is not asked. It directly send tweet. It ask tweet permission for the first time only. Not after de-activate -- Re-activate process. Is this is how Twitter behaves?

Edit 1

Code I use for all tweet is as below...

if ([self userHasAccessToTwitter]) {

    ACAccountStore *account = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];


    // Request access from the user to access their Twitter account
    [account requestAccessToAccountsWithType:accountType options:NULL completion:^(BOOL granted, NSError *error)
     {
         if (granted == YES)
         {

             ///////////////////////////////////////////////
             //           SEND TEXT ONLY                 ///
             ///////////////////////////////////////////////
             [[NSUserDefaults standardUserDefaults] setValue:@"yes" forKey:@"twitterLogin"];
             [[NSUserDefaults standardUserDefaults] synchronize];


             // Populate array with all available Twitter accounts
             NSString *message1 = [NSString stringWithFormat:@"Hi! I am using twitter integration."];
             NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
             if ([arrayOfAccounts count] > 0)
             {
                 //use the first account available
                 ACAccount *acct = [arrayOfAccounts objectAtIndex:0];

                 SLRequest *postRequest1 = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL   URLWithString:@"http://api.twitter.com/1.1/statuses/update.json"] parameters:  [NSDictionary dictionaryWithObject:message1 forKey:@"status"]];
                 [postRequest1 setAccount:acct];//set account
                 [postRequest1 performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                     if(error) {
                         NSLog(@"error == %@", error);
                     } else {
                         NSLog(@"good to go -1- %i", [urlResponse statusCode]);
                     }

                 }];
             }
         }
     }];
}

Solution

  • end_session in API v1 never worked as it should anyway. Starting from 1.1 this method was removed and there's no alternative method. The user should decide if he wants to revoke your application access to his twitter account. The only thing you could do is to delete the auth_token.