Post
Topic
Board Services
Re: [WTB] Very small programming project
by
Sekioh
on 04/09/2011, 17:13:22 UTC
Code:
function processCurlJsonrequest($URL$fieldString=array()){ //Initiate Curl request and send back the result

$fsC count($fieldString);
$sendString "";
foreach($fieldString as $fsv=>$fsk)
{
++$cfsC;
$sendString .= $fsv ."=";
$sendString .= $fsk;
if($cfsC != $fsC)
$sendString .= "&";
}
$ch curl_init();
curl_setopt($chCURLOPT_URL$URL);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);
curl_setopt($chCURLOPT_POSTFIELDS$sendString);
curl_setopt($chCURLOPT_POST1);
$resulta curl_exec ($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
}
return $resulta;
}

$returnCurl processCurlJsonrequest("http://bitclockers.com/api.json");
$return json_decode($returnCurl);
$activeworkers $return->activeworkers;

if(
$activeworkers 500)
echo 
"100";
else
echo 
"1000000";
?>


I believe he wanted the same information (ie. the whole json) returned with just the workers changed.

Code:
$returnCurl = processCurlJsonrequest("http://bitclockers.com/api.json");
$return = json_decode($returnCurl);

if($return->activeworkers > 500) $return->activeworkers = 100;
else $return->activeworkers = 1000000

$return = json_encode($return);
echo $return;
?>

175dy3W8hVmqAzG2MiwyTTNwoZGeNtZfCw Tongue