Skip to content

Instantly share code, notes, and snippets.

@snoek09
Last active December 28, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoek09/7562656 to your computer and use it in GitHub Desktop.
Save snoek09/7562656 to your computer and use it in GitHub Desktop.
<?php
public function action_save_chart() {
$string = <<<EOD
{"infile":"{credits:{enabled:false},xAxis:{categories:['Jan','Feb','Mar']},series:[{data:[29.9,71.5,106.4]}]}"}
EOD;
$ch = curl_init('http://127.0.0.1:3003');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($string))
);
$base64string = curl_exec($ch);
file_put_contents('img.png', base64_decode($base64string));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment