2014-03-27 3 views
0
나는 모든 https://github.com/kylebrowning/drupal-ios-sdk 첫 번째로 언급 한 바와 같이 내가 모든 것을 구성한 드루팔 7 사용하여 구현되는 내 로컬 호스트의 문제 loggingout에 봉착

, 나는 시간의 그의 엄청난 금액을 지출에 대한 kylebrowning 감사 싶어 이 멋진 SDK를 만들 수 있습니다. 내가 직면하고있는 문제는 잘 로그인 할 수 있지만 로그 아웃에 실패했습니다. NSLog 코드의 오류를 확인하십시오. 출력 탭에 표시되는 오류는 다음과 같습니다. 내가 두 개 이상의 링크 를 게시 할 수있는 충분한 명성을하지 않는 것은 여기 아래에있는 내 HTTP, "192.168.1.24/drupal/rest/user/logout"AFNetworkingError IOS에 SDK 드루팔

도메인 = AFNetworkingErrorDomain 코드 = -1011 "예상 상태 안에 무엇을 userInfo = 0x8c4d6c0 {NSLocalizedRecoverySuggestion = [ "CSRF 유효성 검사 실패"], AFNetworkingOperationFailingURLRequestErrorKey = {URL : ">"http : //}, NSErrorFailingURLKey = http :, NSLocalizedDescription = 예상되는 상태 코드는 (200-299) (200-299), 401, AFNetworkingOperationFailingURLResponseErrorKey = {URL : http : //} {상태 코드 : 401, 헤더 { "Cache-Control"= "no-cache, re-revalidate, post-check = 0, pre -check = 0 "; 연결 = "연결 유지"; "Content-Length"= 26; "Content-Type"= "application/json"; 날짜 = "2014 년 3 월 27 일 09:10:32 GMT"; Etag = "\"1395911432 \ ""; 만료 = "일요일, 1979 년 11 월 19 일, 05:00:00 GMT"; "Keep-Alive"= "시간 초과 = 5, 최대 = 98"; "Last-Modified"= "Thu, 2014 년 3 월 27 일 09:10:32 +0000"; 서버 = "Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8y DAV/2 PHP/5.5.3"; "Set-Cookie"= "SESS0fd8593946486e6ecd06721db47d9fe9 = 삭제, 만료 = 1970 년 1 월 1 일 00:00:01 GMT, 최대 연령 = 0, 경로 = /; httponly"; Vary = 동의 함; "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 

입니다. 마지막으로 이것을 사용

- (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]; 

}

나를 위해 작동 : getCSRFTokenWithSuccess에 토큰이처럼 제대로 잘 살고 경우 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) {...} 

에서

답변

0

찾기 및 확인 :

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

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

} 
];