<?php
/* Following is the PHP CURL code to get list of pieces related to your account from Vesica API. Please 
 * note that all the form fields given below are mandatory and must be filled with correct values.
 */
$data = array();

/* Specify API keys below. To get user_api and account_api, you need to login into your Vesica account and 
 * click on "Settings". On settings page click on "API Keys". You would be redirected to the page where 
 * your API keys are being displayed.*/

// specify data to be posted
$data['user_api'] = 'your-user-api-key';
$data['account_api'] = 'your-account-api-key';
$data['demand'] = 'PIECE_LIST';

// URL-ify the data for the POST
$post_str = '';
foreach($data as $key=>$val) {
	$post_str .= $key.'='.urlencode($val).'&';

}
$post_str = substr($post_str, 0, -1);


// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, 'http://vesica.ws/api/index.php' );
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

// grab URL and pass it to the browser
$result = curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

// print response
echo $result;


?>