Report generation returns blank screen

28 views
Skip to first unread message

braimah jake

unread,
Oct 28, 2022, 10:48:23 AM10/28/22
to AdSense API Forum
Hi,

I am working with the Google APIs Client Library for PHP 

I can successfully authenticate and refresh tokens,  but cannot generate reports.

Here's a sample of my code:

        $params = array(
            'date_range' => ['YESTERDAY'],
            'metrics' => [
                'PAGE_VIEWS', 'AD_REQUESTS', 'AD_REQUESTS_COVERAGE',
                'CLICKS', 'AD_REQUESTS_CTR', 'COST_PER_CLICK',
                'AD_REQUESTS_RPM', 'ESTIMATED_EARNINGS'
            ],

        );

        $optParams = array('metric' => array('PAGE_VIEWS', 'CLICKS', 'ESTIMATED_EARNINGS'), 'dimension' => 'AD_UNIT_ID', 'AD_UNIT_NAME');

        $report = $httpClient->get("https://adsense.googleapis.com/v2/accounts/MY-ACCOUNT/?" . http_build_query($optParams) . "/reports:generate");

        return json_decode($report->getBody());


Ad Sense API

unread,
Oct 28, 2022, 11:25:48 AM10/28/22
to braim...@gmail.com, adsen...@googlegroups.com
Thanks for your question.

I suggest trying the interactive API explorer at https://developers.google.com/adsense/management/reference/rest/v2/accounts.reports/generate to check your request.

If that fails, perhaps you could share the errors you are getting, which should help diagnose the problem.

Regards,
Andrew, AdSense API team

ref:_00D1U1174p._5004Q2fpGLd:ref
Reply all
Reply to author
Forward
0 new messages