Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS SDK Drupal上出现网络错误_Ios_Rest_Drupal_Drupal 7 - Fatal编程技术网

IOS SDK Drupal上出现网络错误

IOS SDK Drupal上出现网络错误,ios,rest,drupal,drupal-7,Ios,Rest,Drupal,Drupal 7,我在注销本地主机时遇到问题,这是使用Drupal7实现的 我已按所述配置了所有内容 首先,我要感谢kylebrowning花费大量时间来创建这个很棒的SDK。 我面临的问题是,我可以很好地登录,但我没有成功注销。 我需要登录以查看代码的错误。 下面是“输出”选项卡上显示的错误。 我没有足够的声誉发布两个以上的链接 下面是我的http中的内容,“192.168.1.24/drupal/rest/user/logout” Domain=AFNetworkingErrorDomain Code=-10

我在注销本地主机时遇到问题,这是使用Drupal7实现的 我已按所述配置了所有内容 首先,我要感谢kylebrowning花费大量时间来创建这个很棒的SDK。 我面临的问题是,我可以很好地登录,但我没有成功注销。 我需要登录以查看代码的错误。 下面是“输出”选项卡上显示的错误。 我没有足够的声誉发布两个以上的链接 下面是我的http中的内容,“192.168.1.24/drupal/rest/user/logout”

Domain=AFNetworkingErrorDomain Code=-1011“预期状态代码在(200-299)中,获得401”UserInfo=0x8c4d6c0{NSLocalizedRecoverysSuggestion=[“CSRF验证失败”],AFNetworkingOperationFailingURLRequestErrorKey={URL:“>”http://},NSErrorFailingURLKey=http:,NSLocalizedDescription=预期状态代码在(200-299)中,获取401,AFNetworkingOperationFailingURLResponseErrorKey={URL:http://}{状态代码:401,标头{ “缓存控制”=“无缓存,必须重新验证,后检查=0,预检查=0”; 连接=“保持活动”; “内容长度”=26; “内容类型”=“应用程序/json”; 日期=“2014年3月27日星期四09:10:32 GMT”; Etag=“\”1395911432\”; Expires=“1978年11月19日星期日05:00:00 GMT”; “保持活动”=“超时=5,最大=98”; “上次修改”=“2014年3月27日星期四09:10:32+0000”; Server=“Apache/2.2.25(Unix)mod_ssl/2.2.25 OpenSSL/0.9.8y DAV/2 PHP/5.5.3”; “设置Cookie”=“SESS0fd8593946486e6ecd06721db47d9fe9=已删除;过期时间=周四,1970年1月1日00:00:01 GMT;最大期限=0;路径=/;仅httponly”; 改变=接受; “X-Powered-By”=“PHP/5.5.3”; }}}

这是我的密码

#import "AfterLoginViewController.h"
#import "DIOSUser.h"
#import "DIOSSession.h"
#import "DIOSSystem.h"
@interface AfterLoginViewController ()

@end

@implementation AfterLoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (IBAction)LogOut {
    [DIOSUser
     userLogoutWithSuccessBlock:^(AFHTTPRequestOperation *op, id response)
    {
        [self alertStatus:@"Logout Successful" :@"Sign Out Successful" :0];
         NSLog(@"Logout Successful");
         [self alertStatus:@"LogOut Successful" :@"LogOut is completed" :0];
         [self performSegueWithIdentifier:@"BackToLogin" sender:self];
         /* Handle successful operation here */
    }

     failure:^(AFHTTPRequestOperation *op, NSError *err)
    {
         [self alertStatus:@"LogOut Failed" :@"LogOut failed Please Try Again !!!" :0 ];
         NSLog (@"Signout failed");
         NSLog (@"%@", err);
    }
     ];

}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void) alertStatus:(NSString *)msg :(NSString *)title :(int) tag
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
                                                        message:msg
                                                       delegate:self
                                              cancelButtonTitle:@"Ok"
                                              otherButtonTitles:nil, nil];
    alertView.tag = tag;
    [alertView show];

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
如果有人能帮我解决这个问题,我将不胜感激。

在DIOSSystem类中查找 这种方法

+ (void)systemConnectwithSuccess: (void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
DIOSSession *session = [DIOSSession sharedSession];
[session getCSRFTokenWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {...}
并检查getCSRFTokenWithSuccess中的令牌设置是否正确,如下所示:

- (void)getCSRFTokenWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                   failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/services/session/token", [[DIOSSession sharedSession] baseURL]]]];
[request setValue:[NSString stringWithFormat:@"text/plain"] forHTTPHeaderField:@"Accept"];
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSString *aCsrfToken = [NSString stringWithUTF8String:[responseObject bytes]];
    [[DIOSSession sharedSession] setCsrfToken:aCsrfToken];
    if (success != nil) {
        success(operation, responseObject);
    }
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    [DIOSSession logRequestFailuretoConsole:operation withError:error];
    if (failure != nil) {
        failure(operation, error);
    }
}];
operation.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain", @"application/json", nil];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[self.operationQueue addOperation:operation];
}

最后使用这个,对我有用:

 [DIOSUser
 userMakeSureUserIsLoggedOutWithSucess:^(AFHTTPRequestOperation *op, id response) {
     NSLog(@"LogOut success!");

 }
 failure:^(AFHTTPRequestOperation *op, NSError *err) {
     NSLog(@"LogOut error: %@",err);

 }
 ];