The bespoke JSON/PHP Code:
<?php
$url = ("<<URL HERE>>");
function new_file_get_contents($url) {
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
$json = new_file_get_contents($url);
$data=json_decode($json);
$uname = get_post_meta($post->ID, 'Json-Name', true);
foreach($data->callCentres as $callCentres){
foreach($callCentres->operators as $operator){
if($operator->username == $uname) {
if ($operator->status == 1) {echo "Currently Online And Available";}
elseif ($operator->status == 2){echo "Currently Online But Busy";}
elseif ($operator->status == 3){echo "Currently Offline";}
}
}
}
?>
where json-name is a custome field.
I have created parent and child templates.
The child displays a user profile, the parent displays a list summary of all the user profiles.
When I use the above code on the child, it's fine.
When I use the above code on the parent, the first user profile is functional, the second gives the error message:
Fatal error: Cannot redeclare new_file_get_contents() (previously declared in ...
The above script is used within
<?php
query_posts(array('showposts' => 23, 'post_parent' => 478, 'post_type' => 'page'));
while (have_posts()) {
the_post(); // vital
?>
Probably something obvious...but I can't see it!
REAL LIFE OF PROBLEM - CLICK HERE
Appreciate somebody's assitance!
Cheers Andy