문제

I want to use the Google AdWords API to pull my clients invoices via php. This will make the process of billing my clients much more streamlined. How would I do this utilizing the AdWords API?

도움이 되었습니까?

해결책 3

Unfortunately, it seems that at this current time, there is no way to retrieve invoices from a Google Adwords account. The workaround I came up with, was to access the linked Google Analytics account via the gapi (http://code.google.com/p/gapi-google-analytics-php-interface/) and generate the invoice myself. This is how to get adwords data for a specific date range:

require("gapi.class.php");
$gapi = new gapi("email","password");
$ga_dimensions = '';
$ga_metrics = array('impressions','adClicks','adCost','CTR','CPC');
$start_date = "2011-03-01";
$end_date = "2011-03-31";
$gapi->requestReportData($ga_profile_id,$ga_dimensions,$ga_metrics,'','',$start_date,$end_date,1,10000);
$ga_adwords_data = $gapi->getResults();
foreach($ga_adwords_data as $ga_adwords_stat) {
    $ga_adwords_stats = array('impressions' => $ga_adwords_stat->getImpressions(),
                              'clicks'      => $ga_adwords_stat->getAdClicks(),
                              'cost'        => $ga_adwords_stat->getAdCost(),
                              'ctr'         => $ga_adwords_stat->getCTR(),
                              'cpc'         => $ga_adwords_stat->getCPC());
}
print_r($ga_adwords_stats);

다른 팁

I'm assuming you want to pull out the cost data associated with specific accounts and/or campaigns so it can be put into invoices. This simplest way to do this is using the reporting service of the AdWords API. Google provides a PHP library to do this that you can download from http://code.google.com/p/google-api-adwords-php/ The download also contains an example demonstrating how to download a report.

Be careful about generating your own invoices. Because click fraud adjustment is an ongoing process, unless you pull your report at the exact moment as Google generates their own invoice, there is a good chance that your numbers will be different from what Google bills. If you are generating invoices on behalf of clients who have access to their own adWords accounts, be prepared to explain why the two invoices don't match.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top