Pour les développeurs, une API gratuite est à votre disposition pour accéder à vos graphiques.
Vous pouvez ainsi récupérer de façon dynamique vos graphes dans vos codes, ou encore ajouter des graphes ou les modifier depuis vos pages extérieures.
<?php
// ** Parameters : You have to set the parameters
$api_key = 'XXXXXXXXXXXX'; // Your API key
$api_pass = ''; // Leave it empty
$api_output = 'json'; // json, or serialize
$api_action = 'graph_byid';
$api_id = '17';
$post = array();
// ** Running the API : You can copy all of this part
$url = 'https://www.share-a-graph.com';
$params = array( 'api_user' => $api_key, 'api_pass' => $api_pass, 'api_action' => $api_action, 'api_output' => $api_output, 'id' => $api_id );
if ( !function_exists('curl_init') ) die('CURL not supported. (introduced in PHP 4.0.2)');
if ( $params['api_output'] == 'json' && !function_exists('json_decode') ) die('JSON not supported. (introduced in PHP 5.2.0)');
$data = "";
foreach( $post as $key => $value ) $data .= $key . '=' . urlencode($value) . '&';
$data = rtrim($data, '& ');
$query = "";
foreach( $params as $key => $value ) $query .= $key . '=' . urlencode($value) . '&';
$query = rtrim($query, '& ');
$url = rtrim($url, '/ ');
$api = $url . '/api/api.php?' . $query;
$request = curl_init($api); // initiate curl object
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($request, CURLOPT_POSTFIELDS, $data); // use HTTP POST to send form data
curl_setopt($request, CURLOPT_NOSIGNAL, 1);
curl_setopt($request, CURLOPT_CONNECTTIMEOUT_MS, 500);
curl_setopt($request, CURLOPT_TIMEOUT_MS, 500);
$response = (string)curl_exec($request); // execute curl post and store results in $response
$result = json_decode($response,true);
curl_close($request);
// ** Output results : You can copy all of this part
( (int) $result['code']!=0 ) ? var_dump($result); var_dump($result['output']);
// Output a graph with headers needed
if ( isset($result['output']['graph']) ) {
$the_graphe = json_decode( $result['output']['graph'] );
$headers = <<< EOT
<html>
<head>
<script type="text/javascript" src="https://www.share-a-graph.com/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="https://www.share-a-graph.com/js/jquery-ui-1.8.24.custom.min.js"></script>
<script type='text/javascript' src='https://www.share-a-graph.com/js/highcharts.js'></script>
</head>
<body>
EOT;
print $headers;
print $the_graphe;
print "</body></html>";
}