我不得不将客户应用中的RestKit框架升级到0.2x版本。 在旧版本中,以下代码用于登录用户:
startWindowImpl
现在我正在尝试将其转换为以下代码,但它不起作用:
MySingleton *singleton = [MySingleton sharedInstance];
NSString *token = singleton.oauth_token;
NSString *secret = singleton.oauth_token_secret;
EnvironmentSingleton *environmentSingleton = [EnvironmentSingleton sharedInstance];
NSString *resourcePath = [NSString stringWithFormat:@"%@/api/user", environmentSingleton.base_url];
RKParams* params = [RKParams params];
[params setValue:token forParam:@"token"];
[params setValue:secret forParam:@"secret"];
[params setValue:txtEmail.text forParam:@"email"];
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[UserInfo class]];
[objectMapping mapKeyPath:@"_appId" toAttribute:@"appId"];
[objectMapping mapKeyPath:@"_fullName" toAttribute:@"fullName"];
[objectMapping mapKeyPath:@"_domainUrn" toAttribute:@"domainUrn"];
RKObjectLoader *objectLoader = [[RKObjectManager sharedManager] loaderWithResourcePath:resourcePath];
objectLoader.method = RKRequestMethodPOST;
objectLoader.objectMapping = objectMapping;
objectLoader.params = params;
objectLoader.delegate = self;
@try
{
[objectLoader send];
}
@catch (NSException *exception)
{
NSLog(@"NSException - Name: %@, Reason: %@", exception.name, exception.reason);
}
我刚才注意到我没有在任何地方发送参数,所以也许这就是我得到406错误的原因。但是如何发送它们?