을 사용하여 AFNetworking 2.0을 사용하여 응답을 얻을 수 없습니다.이 방법을 사용하여 데이터를 가져올 수 없지만 다른 URL을 사용할 때 작동하지만 응답을받는 우편 발송자에서 테스트했습니다.GET 메서드
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
// if you want to sent parameters you can use above code
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager GET:@"http://192.168.1.156:81/a.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"responseObject %@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
오류 :
"Request failed: unacceptable content-type: text/html" UserInfo=0x8a6b000 {NSErrorFailingURLKey=http://192.168.1.156:81/a.php, AFNetworkingOperationFailingURLResponseErrorKey= { URL: http://192.168.1.156:81/a.php } { status code: 200, headers { Connection = "Keep-Alive"; "Content-Type" = "text/html"; Date = "Tue, 20 May 2014 14:49:20 GMT"; "Keep-Alive" = "timeout=5, max=100"; Server = "Apache/2.4.4 (Win64) PHP/5.4.12"; "Transfer-Encoding" = Identity; "X-Powered-By" = "PHP/5.4.12"; } }, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}
있는 NSArray 변환 오류 :
Parsing JSON failed: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid escape sequence around character 4677.) UserInfo=0xa82c130 {NSDebugDescription=Invalid escape sequence around character 4677.}
Parse error on line 258: ... "story_title": "today\'s story", -----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
'failure' 블록에서'NSError' 객체를 검사 해 보셨습니까? 그것은 무엇을 말하는가? – Rob
@Rob - 내 질문에 대답이 – user3635892
업데이트되었습니다. 질문에 관련이 없지만, BTW, 'GET' 요청에 대해 AFJSONRequestSerializer를 지정하는 것이 조금 궁금합니다. 'GET' 요청에는 본문이 없지만 URL에 매개 변수가 인코딩됩니다. 게다가 매개 변수가 없습니다. – Rob