【问题标题】:how to deactivate twitter account in iPhone app that used for Integration如何在用于集成的 iPhone 应用程序中停用 Twitter 帐户
【发布时间】:2014-01-31 21:29:18
【问题描述】:

我有一个应用程序,我在其中进行 Twitter 集成。

我能够成功发推文。

现在当我想停用时,我在下面使用。

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

问题是 API 为 1 已弃用,我在 1.1 中找不到此方法。

有什么替代品吗?

我还注意到,当我再次尝试激活时,没有询问权限。它直接发送推文。 它只在第一次请求推文许可。停用后没有——重新激活过程。这就是 Twitter 的行为方式吗?

编辑 1

我用于所有推文的代码如下...

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]);
                     }

                 }];
             }
         }
     }];
}

【问题讨论】:

    标签: objective-c twitter slrequest


    【解决方案1】:

    API v1 中的end_session 无论如何都无法正常工作。从 1.1 开始,此方法已被删除,并且没有替代方法。用户应决定是否要撤消您的应用程序对其 Twitter 帐户的访问权限。你唯一能做的就是删除auth_token

    【讨论】:

    • 知道如何删除 auth_token
    • @FahimParkar 当您从 twitter 请求令牌时,您将其存储在您的应用程序中。使用 _yourToken = nil; 从那里删除它
    • 查看我编辑的问题...我没有在应用程序中保存令牌数据...我每次都在请求...知道如何在我的情况下删除?
    • 你不能用给定的 API 做到这一点。
    • 那我该怎么办? bcz 这就是我在用户墙上自动发布推文的方式......
    猜你喜欢
    • 2011-11-03
    • 2011-09-03
    • 2011-09-14
    • 2011-06-14
    • 1970-01-01
    • 1970-01-01
    • 2011-03-09
    • 2012-02-04
    • 2012-02-04
    相关资源
    最近更新 更多