So, i dont understand some things.
1. Go to settings on my ADMOB account and get my 'pub-XXXXXXXXXX'
{
"report_spec": {
"date_range": {
"start_date": {"year": 2020, "month": 6, "day": 20},
"end_date": {"year": 2020, "month": 6, "day": 30}
},
"dimensions": ["DATE"],
"metrics": ["CLICKS", "AD_REQUESTS", "IMPRESSIONS", "ESTIMATED_EARNINGS"],
"dimension_filters": [{"dimension": "COUNTRY", "matches_any": {"values": ["US"]}}],
"sort_conditions": [{"metric":"CLICKS", order: "DESCENDING"}],
"localization_settings": {"currency_code": "USD", "language_code": "en-US"}
}
}
EOF;
$auth_token = 'my_auth_token_from_step_2';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '. $auth_token , "Content-Type: application/json" ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
var_dump($result);
And it works only 3600 seconds.