<?php
// ** Parameters : You have to set the parameters
$api_key = 'XXXXXXXXXXXX';
$api_pass = ''; // Leave it empty
$api_output = 'json'; // json, or serialize
$api_action = 'graph_publiclist';
$api_id = '';
$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']);