访问用户的iOS默认Twitter帐户iOS [英] Access user's iOS default Twitter account iOS

查看:101
本文介绍了访问用户的iOS默认Twitter帐户iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试访问用户的iOS默认Twitter帐户.

I try to access my user's iOS default Twitter account.

我使用STTwitter库.下面的代码曾经在我的设备上可以正常工作,但现在不是.返回的"oAuthToken","oAuthTokenSecret"和"userID"为零.但它仍在模拟器上运行

I use STTwitter library. The below code used to work fine on my device, but now it's not. The returned "oAuthToken", "oAuthTokenSecret", and "userID" are nil. but it's still working on the simulator

STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
                                                          consumerKey:@"myConsumerKey"
                                                       consumerSecret:@"myConsumerSecret"];

[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {

    STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];

    [twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {

        [twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
                                                            successBlock:^(NSString *oAuthToken,
                                                                           NSString *oAuthTokenSecret,
                                                                           NSString *userID,
                                                                           NSString *screenName) {


                                                                // use the tokens...
                                                                self.oAuthToken = oAuthToken;
                                                                self.oAuthTokenSecret = oAuthTokenSecret;

                                                                if(self.oAuthToken && self.oAuthTokenSecret){
                                                                    completionHandler();

                                                                }
                                                                else{

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

                                                                    NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];

                                                                    [account renewCredentialsForAccount:[arrayOfAccounts firstObject] completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {

                                                                             [self getUserTwitterDataFromPhoneSettingsInView:view WithCompletionHandler:completionHandler];

                                                                    }];



                                                                }

                                                            } errorBlock:^(NSError *error) {
                                                                // Error

                                                            }];

    } errorBlock:^(NSError *error) {
        // no twitter account
        // user denied access to their account(s)

    }];

} errorBlock:^(NSError *error) {
    // ...

}];

推荐答案

由于某种原因,事实证明,在"iOS设置"中输入的Twitter帐户缺少"oauth_token"属性,可能需要再次进行验证.可能的解决方法是转到"iOS设置",然后再次设置帐户.现在,我将尝试在STTwitter中找到一种检测此状态的方法.

For some reason, it turns out that the Twitter account entered in iOS Settings lacks the 'oauth_token' property and may need to be validated again. A possible fix is to go to iOS Settings and setup the account again. Now, I'll try to find a way to detect this state in STTwitter.

这篇关于访问用户的iOS默认Twitter帐户iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆