-1

我想从 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>

请问有什么帮助吗?

4

1 回答 1

2

那是二进制数据。你应该转换它。

尝试NSString *response = [[NSString alloc] initWithData:(NSData*)responseObject encoding:NSUTF8StringEncoding];以字符串形式获取响应

或简单: NSString *response = request.responseString;

于 2013-01-10T14:24:37.700 回答