Этот код работает. Вам нужно будет изменить его, чтобы сохранить ваш ключ API, хотя
<code><?php
//Initiate a curl request
$ch = curl_init();
//This is your API key
$apiKey = "xxxx";
//These are your postFields
$postFields = array(
"start_date" => "2016-08-02",
"end_date" => "2016-08-03",
"columns" => array(
"paid_impressions",
"revenue"
)
);
//Setup the curl options using variables in place of your postFields and apiKey
curl_setopt($ch, CURLOPT_URL, "http://udmserve.com/udm/radalytics_api.cpx?action=report&api_key=" . $apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $postFields ));
curl_setopt($ch, CURLOPT_POST, 1);
//Set up the request headers
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//Make the request
$result = curl_exec($ch);
//If there was an error, display error code
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
//Delete the curl object
curl_close ($ch);
//Show the result
echo $result;
//Or, print as array
echo '<pre>'. print_r( json_decode($result), 1 ) .'
';