我想从PhP页面获取数据 我的代码是
NSURL *url = [NSURL URLWithString:@"http://avicenna-apps.com/harleychatget.php"];
AFHTTPClient * Client = [AFHTTPClient clientWithBaseURL:url];
[Client defaultValueForHeader:@"Accept"];
[Client getPath:@"" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"Data %@",responseObject);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error retrieving data: %@", error);
}];
输出
Data <32352020 32303133 2d30312d 31302030 383a3234 3a353620 2041686d 65642020 68656c6c 6f206865 6c6c6f20 3c627220 2f3e3234 20203230 31332d30 312d3130 2030383a 32343a35 30202041 686d6564 20203c62 72202f3e 32332020 32303133 2d30312d 31302030 383a3234 3a343920 2041686d 65642020 3c627220 2f3e3230 20203230 31332d30 312d3130 2030383a 32343a34 38202041 686d6564 20203c62 72202f3e 32312020 32303133 2d30312d 31302030 383a3234 3a343820 2041686d 65642020 3c627220 2f3e200a 0a>
请帮忙吗?
答案 0 :(得分:2)
那是二进制数据。你应该转换它。
尝试NSString *response = [[NSString alloc] initWithData:(NSData*)responseObject encoding:NSUTF8StringEncoding];
以字符串
或简单:
NSString *response = request.responseString;