I'm trying to write an iOS (5) app that uses json objects to get data from a server. im calling a php script from the app, that gets the data from the server, encodes it as json, and then outputs it. the line in the php script that does that is:
$json_encoded = json_encode($normal_array, JSON_FORCE_OBJECT)
echo $json_encoded;
but when I do:
NSURL *url = [NSURL URLWithString:@"192.168.1.100/testing/get.php?number=5"];
NSData *data = [NSData dataWithContentsOfURL:url];
the data variable is of size 0 bytes and contains no data.
Can anyone tell me why the dataWithContentsOfURL gets something thats empty? Is it not enough to echo? Do i need to send a response or something like that? If so, how would I send a response from the php script? If i call the exact same script in a browser, it outputs:
{
"0": {
"0":"asdfgh",
"1":"2012-06-11 16:21:15"
},
"1": {
"0":"jumps over",
"1":"2012-06-11 16:20:52"
},
"2": {
"0":"the quick brown fox",
"1":"2012-06-11 16:20:40"
},
"3": {
"0":"the quick brown fox",
"1":"2012-06-11 16:20:40"
},
"4": {
"0":"the quick brown fox",
"1":"2012-06-11 16:20:21"
}
}
which is a valid JSON object, as far as I know.