带结构的Twitter SDK ios

带结构的Twitter SDK ios,ios,objective-c,twitter-fabric,Ios,Objective C,Twitter Fabric,我需要在我的iOS应用程序中实现twitter登录,我已经用fabric SDK安装了twitter框架。这是我第一次在登录时面对这个问题。我可以接收令牌详细信息 推特详细信息:@TestUserApp已登录!(796637020760186880) 身份验证令牌:796637020760186880-ieeZM2Mbn3FLutLOcJ1sk7bp83ZSlzU 身份验证令牌密钥:1G0O5YDF89V0VTONMDY8W3UI2PKNVKGTNPQRLEOIOB 错误:错误域=Twitter

我需要在我的iOS应用程序中实现twitter登录,我已经用fabric SDK安装了twitter框架。这是我第一次在登录时面对这个问题。我可以接收令牌详细信息

推特详细信息:@TestUserApp已登录!(796637020760186880)

身份验证令牌:796637020760186880-ieeZM2Mbn3FLutLOcJ1sk7bp83ZSlzU

身份验证令牌密钥:1G0O5YDF89V0VTONMDY8W3UI2PKNVKGTNPQRLEOIOB

错误:错误域=TwitterApierDomain代码=99“请求失败: 禁止(403)“UserInfo={NSLocalizedFailureReason=Twitter API错误 :无法验证您的凭据(代码99), TWTRNetworkingStatusCode=403, NSErrorFailingURLKey=, NSLocalizedDescription=请求失败:禁止(403)}

完整代码:

TWTRLogInButton *logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) {
    if (session) {

        NSString *authToken = session.authToken;
        NSString *authTokenSecret = session.authTokenSecret;
        NSString* userId = session.userID;
        NSString *message = [NSString stringWithFormat:@"@%@ logged in! (%@) -Auth token:%@ -Auth Token secret:%@",
                             [session userName], [session userID],authToken,authTokenSecret];

        // Objective-C
        TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
        [client loadUserWithID:userId completion:^(TWTRUser *user, NSError *error) {
            if (error == nil) {
                 NSLog(@"Name:%@ -- ScreenName:%@ -- ProfileImageUrl:%@",user.name,user.screenName,user.profileImageURL);
            }
            else {
                NSLog(@"Error:%@",error.description);
            }

        }];

    } else {
        NSLog(@"Login error: %@", [error localizedDescription]);
    }
}];
//应用程序内代理

#import <Fabric/Fabric.h>
#import <TwitterKit/TwitterKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Fabric with:@[[Twitter class]]];
}
#导入
#进口
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
[Fabric with:@[[Twitter类]];
}
//你的控制器

#import <TwitterKit/TwitterKit.h>


[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBased completion:^(TWTRSession *session, NSError *error)
 {
     if (session)
     {

         TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
         NSURLRequest *request = [client URLRequestWithMethod:@"GET"
                                                          URL:@"https://api.twitter.com/1.1/account/verify_credentials.json"
                                                   parameters:@{@"include_email": @"true", @"skip_status": @"true"}
                                                        error:nil];

         [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError)
          {

              if (data)
              {
                  // handle the response data e.g.
                  NSError *jsonError;
                  NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
                  NSLog(@"Twiiter json is ====>%@",json);

                  NSString *userid =[json objectForKey:@"id"];
                  NSString *strtwitter =[NSString stringWithFormat:@"%@",@"https://twitter.com/intent/user?user_id=",userid];
                  NSLog(@"strtwitter is ===>%@",strtwitter);

                   [self dataSendToTwitter:json];

              }
              else {
                  NSLog(@"Error: %@", connectionError);
              }


          }];



     } else {
         NSLog(@"error: %@", [error localizedDescription]);
     }
 }];
#导入
[[Twitter sharedInstance]登录方法:TWTRLoginMethodWebBased完成:^(TWTRSession*会话,NSError*错误)
{
国际单项体育联合会(届会)
{
TwtrapClient*客户端=[TwtrapClient客户端WithCurrentUser];
NSURLRequest*request=[客户端URLRequestWithMethod:@“GET”
网址:@“https://api.twitter.com/1.1/account/verify_credentials.json"
参数:@{@“include_email”:@“true”,“skip_status”:@“true”}
错误:无];
[客户端sendTwitterRequest:请求完成:^(NSURLResponse*response,NSData*data,NSError*connectionError)
{
如果(数据)
{
//处理响应数据,例如。
n错误*jsonError;
NSDictionary*json=[NSJSONSerialization JSONObject WithData:数据选项:0错误:&jsonError];
NSLog(@“Twiiter json为===>%@”,json);
NSString*userid=[json objectForKey:@“id”];
NSString*strtwitter=[NSString stringWithFormat:@“%@,@”https://twitter.com/intent/user?user_id=“,userid];
NSLog(@“strtwitter is===>%@”,strtwitter);
[self-datasendtowitter:json];
}
否则{
NSLog(@“错误:%@”,connectionError);
}
}];
}否则{
NSLog(@“错误:%@,[error localizedDescription]);
}
}];
//应用程序内委托

#import <Fabric/Fabric.h>
#import <TwitterKit/TwitterKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Fabric with:@[[Twitter class]]];
}
#导入
#进口
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
[Fabric with:@[[Twitter类]];
}
//你的控制器

#import <TwitterKit/TwitterKit.h>


[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBased completion:^(TWTRSession *session, NSError *error)
 {
     if (session)
     {

         TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
         NSURLRequest *request = [client URLRequestWithMethod:@"GET"
                                                          URL:@"https://api.twitter.com/1.1/account/verify_credentials.json"
                                                   parameters:@{@"include_email": @"true", @"skip_status": @"true"}
                                                        error:nil];

         [client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError)
          {

              if (data)
              {
                  // handle the response data e.g.
                  NSError *jsonError;
                  NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
                  NSLog(@"Twiiter json is ====>%@",json);

                  NSString *userid =[json objectForKey:@"id"];
                  NSString *strtwitter =[NSString stringWithFormat:@"%@",@"https://twitter.com/intent/user?user_id=",userid];
                  NSLog(@"strtwitter is ===>%@",strtwitter);

                   [self dataSendToTwitter:json];

              }
              else {
                  NSLog(@"Error: %@", connectionError);
              }


          }];



     } else {
         NSLog(@"error: %@", [error localizedDescription]);
     }
 }];
#导入
[[Twitter sharedInstance]登录方法:TWTRLoginMethodWebBased完成:^(TWTRSession*会话,NSError*错误)
{
国际单项体育联合会(届会)
{
TwtrapClient*客户端=[TwtrapClient客户端WithCurrentUser];
NSURLRequest*request=[客户端URLRequestWithMethod:@“GET”
网址:@“https://api.twitter.com/1.1/account/verify_credentials.json"
参数:@{@“include_email”:@“true”,“skip_status”:@“true”}
错误:无];
[客户端sendTwitterRequest:请求完成:^(NSURLResponse*response,NSData*data,NSError*connectionError)
{
如果(数据)
{
//处理响应数据,例如。
n错误*jsonError;
NSDictionary*json=[NSJSONSerialization JSONObject WithData:数据选项:0错误:&jsonError];
NSLog(@“Twiiter json为===>%@”,json);
NSString*userid=[json objectForKey:@“id”];
NSString*strtwitter=[NSString stringWithFormat:@“%@,@”https://twitter.com/intent/user?user_id=“,userid];
NSLog(@“strtwitter is===>%@”,strtwitter);
[self-datasendtowitter:json];
}
否则{
NSLog(@“错误:%@”,connectionError);
}
}];
}否则{
NSLog(@“错误:%@,[error localizedDescription]);
}
}];
遵循此链接遵循此链接