<?php
// query parameters
$url = 'http://xxxxxxxx.com/blog/'; // URL to short
$keyword = 'xxxxx';				// optional keyword
$format = 'xxxxx';				// output format: 'json', 'xml' or 'simple'
// URL of the API file
$api_url = 'http://djaw.ir/api.php';
// Init the CURL session
$dj = curl_init();
curl_setopt($dj, CURLOPT_URL, $api_url);
curl_setopt($dj, CURLOPT_HEADER, 0);            // No header in the result
curl_setopt($dj, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result
curl_setopt($dj, CURLOPT_POST, 1);              // This is a POST request
curl_setopt($dj, CURLOPT_POSTFIELDS, array(     // Data to POST
		'url'      => $url,
		'keyword'  => $keyword,
		'format'   => $format,
		'action'   => 'shorturl'
	));
// Fetch and return content
$data = curl_exec($dj);
curl_close($ch);
// Do something with the result. Here, we just echo it.
echo $data;
?>