получение баланса аккаунта adwords

607 views
Skip to first unread message

adw...@prime-ltd.su

unread,
Aug 2, 2016, 4:02:29 AM8/2/16
to AdWords API Forum
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

Joyce Lava

unread,
Aug 2, 2016, 5:04:32 AM8/2/16
to AdWords API Forum
Hi,

Apologies, I can only provide support in English. There is currently no AdWords API service that returns the remaining balance of an account. However, if you know the original budget, you may use the ACCOUNT_PERFORMANCE_REPORT to get the Cost and subtract that from the original budget.

Hope this helps.

Best Regards,
Joyce, AdWords API Team

adw...@prime-ltd.su

unread,
Aug 2, 2016, 8:03:05 AM8/2/16
to AdWords API Forum
you can set an example query? 

Joyce Lava

unread,
Aug 2, 2016, 10:10:52 PM8/2/16
to AdWords API Forum
Hi,

You may use the example code (Java client library) that shows how to generate report using AdWords API. Other client library examples are available on the same link. You need to set the reportType as ACCOUNT_PERFORMANCE_REPORT and include the Cost field in the Selector. That way, you can get the cost of the AdWords account which you can then subtract with the original budget. I'm afraid you have to do the subtraction on your side since there is currently no way to get the original budget through the AdWords API.

All available fields in the report can also be seen in the link provided. Hope this helps.

Thanks and Regards,
Joyce, AdWords API Team

adw...@prime-ltd.su

unread,
Aug 30, 2016, 11:26:10 AM8/30/16
to AdWords API Forum
Can you describe how to make a request to the procedural form without the use of your class???

вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:

Joyce Lava

unread,
Aug 30, 2016, 10:34:11 PM8/30/16
to AdWords API Forum
Hello,

The example code provided in my previous response was intended to be a reference on how you will be able to generate a report in AdWords API. If you will have to create your own report query, then you may refer to the different report types to see what are the columns available in the report you wish to generate. 

For example, to generate the Account Performance Report with Cost field, you may opt to use AWQL or XML report definition, for instance in AWQL, you will have to do something like: SELECT Cost, <any other column fields you wish to get> FROM ACCOUNT_PERFORMANCE_REPORT DURING <the date range you wish to obtain>. This page discusses more details about report definition. Hope this helps.

Thanks,
Joyce, AdWords API Team

adw...@prime-ltd.su

unread,
Aug 31, 2016, 4:05:58 AM8/31/16
to AdWords API Forum
I do so:

$xml = '<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201506">
  <selector>
    <fields>CampaignId</fields>
    <fields>Id</fields>
    <fields>Impressions</fields>
    <fields>Clicks</fields>
    <fields>Cost</fields>
    <predicates>
      <field>Status</field>
      <operator>IN</operator>
      <values>ENABLED</values>
      <values>PAUSED</values>
    </predicates>
  </selector>
  <reportName>Custom Adgroup Performance Report</reportName>
  <reportType>ADGROUP_PERFORMANCE_REPORT</reportType>
  <dateRangeType>LAST_7_DAYS</dateRangeType>
  <downloadFormat>CSV</downloadFormat>
</reportDefinition>';

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);


var_dump($server_output);

//////////////////////////////////////////////////////////

 you can fix the code to make it work. I got all the tokens

вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

Joyce Lava

unread,
Aug 31, 2016, 4:43:21 AM8/31/16
to AdWords API Forum
Hi,

Could you please confirm if you receive any error after running the report? I'm not quite sure on what you meant by "fix the code to make it work". Based from the original post in this thread, you were asking how to get the balance of an account, and that, I responded that there is no AdWords API service or report that will return the balance, what I suggested is to run the Account Performance Report and get the Cost field value and then perform a subtract on your side from the original budget so you will get the balance of the account.

In your most recent post, you are generating an AdGroup Performance Report and that you are using a very old version (v201506). Could you please clarify what specific issue you are running into? Also, I highly recommend that you migrate to the latest version (v201607) to avoid any issues.

adw...@prime-ltd.su

unread,
Aug 31, 2016, 4:57:59 AM8/31/16
to AdWords API Forum
yes I am interested in how to get Account Performance Report? you can write an example of how to get it through curl. Please!!!!!


вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

adw...@prime-ltd.su

unread,
Aug 31, 2016, 4:59:19 AM8/31/16
to AdWords API Forum


вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

Michael Cloonan (AdWords API Team)

unread,
Aug 31, 2016, 8:23:08 AM8/31/16
to AdWords API Forum
Hello,

You can see a full example request, made via cURL, here: https://developers.google.com/adwords/api/docs/guides/reporting#complete_example

From there you should be able to determine how to set your parameters locally to generate the request.

I think a better approach, however, might be to use our PHP library if you're using PHP locally. You can find that here: https://github.com/googleads/googleads-php-lib

The library includes examples of how to run reports as well, and I think it would save you time overall to use the library's pre-built reporting functionality rather than trying to write your own.

Regards,
Mike, AdWords API Team

adw...@prime-ltd.su

unread,
Aug 31, 2016, 9:01:30 AM8/31/16
to AdWords API Forum
how do I make a request, I do not understand it:

<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/v201506">
 
<selector>
   
<fields>CampaignId</fields>
   
<fields>Id</fields>
   
<fields>Impressions</fields>
   
<fields>Clicks</fields>
   
<fields>Cost</fields>
   
<predicates>
     
<field>Status</field>
     
<operator>IN</operator>
     
<values>ENABLED</values>
     
<values>PAUSED</values>
   
</predicates>
 
</selector>
 
<reportName>Custom Adgroup Performance Report</reportName>
 
<reportType>ADGROUP_PERFORMANCE_REPORT</reportType>
 
<dateRangeType>LAST_7_DAYS</dateRangeType>
 
<downloadFormat>CSV</downloadFormat>
</reportDefinition>
query returns:
string(63) "!!!2|||-1|||Report request does not include report ID or XML???"
please write a request where I insert the token and get a report.
then you can just write a query that I need, all XML in which I insert a token and send it.
вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

Michael Cloonan (AdWords API Team)

unread,
Aug 31, 2016, 9:42:39 AM8/31/16
to AdWords API Forum
Hello,


If the documentation is not providing you enough help to successfully make the request, then I sincerely suggest using the PHP client library I linked in my previous post which handles all the implementation details for you and includes specific examples showing how to make successful requests. There is no better resource than a fully functioning library and example that already does exactly what you want that I can link.

PHP Library homepage with README for setup information: https://github.com/googleads/googleads-php-lib

Regards,
Mike, AdWords API Team

adw...@prime-ltd.su

unread,
Aug 31, 2016, 10:57:50 AM8/31/16
to AdWords API Forum
set the library entered tokens, the answer is:



<b>Fatal error</b>: Uncaught exception 'ReportDownloadException' with message 'Report download failed. Underlying errors are
Type = 'QuotaCheckError.DEVELOPER_TOKEN_NOT_APPROVED', Trigger = '&lt;null&gt;', FieldPath = ''. ' in C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtilsDelegate.php:162
Stack trace:
#0 C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtilsDelegate.php(77): ReportUtilsDelegate::DownloadReportFromUrl('https://adwords...', Array, Array, 'C:\\OpenServer\\d...')
#1 C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtils.php(80): ReportUtilsDelegate::DownloadReport(Object(ReportDefinition), 'C:\\OpenServer\\d...', Object(AdWordsUser), Array)
#2 C:\OpenServer\domains\googleads\index.php(77): ReportUtils-&gt;DownloadReport(Object(ReportDefinition), 'C:\\OpenServer\\d...', Object(AdWordsUser), Array)
#3 C:\OpenServer\domains\googleads\index.php(101): DownloadCriteriaReportExample(Object(AdWordsUser), 'C:\\OpenServer\\d...')
#4 {main}
thrown in <b>C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtilsDelegate.php</b> on line <b>162</b><br />

вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

Michael Cloonan (AdWords API Team)

unread,
Aug 31, 2016, 11:05:30 AM8/31/16
to AdWords API Forum
Hello,

The good news is it looks like the request is formatted properly if you're getting that error. You are simply lacking credentials to make the request. Once you get those, the report should work properly.

Specifically, your developer token is not approved to make requests to the AdWords API. If you recently requested the token, you may still be in the approval process. If you've used the token in the past, it may have been deactivated due to a period of disuse.

You can follow the instructions in our sign up guide to get a new token or restore access to your previous token if you're not currently in the approval process: https://developers.google.com/adwords/api/docs/guides/signup#step_2_apply_for_access_to_the_adwords_api

If you are in the approval process, please just be patient and follow that team's instructions.

Regards,
Mike, AdWords API Team

adw...@prime-ltd.su

unread,
Sep 29, 2016, 8:13:50 AM9/29/16
to AdWords API Forum
Got a basic access, the error is now:

<b>Fatal error</b>: Uncaught exception 'ReportDownloadException' with message 'Report download failed. Underlying errors are
Type = 'ReportDefinitionError.CUSTOMER_SERVING_TYPE_REPORT_MISMATCH', Trigger = '', FieldPath = 'selector'. ' in C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtilsDelegate.php:162
Stack trace:
#0 C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtilsDelegate.php(77): ReportUtilsDelegate::DownloadReportFromUrl('https://adwords...', Array, Array, 'C:/OpenServer/d...')
#1 C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtils.php(80): ReportUtilsDelegate::DownloadReport(Object(ReportDefinition), 'C:/OpenServer/d...', Object(AdWordsUser), Array)
#2 C:\OpenServer\domains\googleads\index.php(37): ReportUtils-&gt;DownloadReport(Object(ReportDefinition), 'C:/OpenServer/d...', Object(AdWordsUser), Array)
#3 C:\OpenServer\domains\googleads\index.php(62): DownloadCriteriaReportExample(Object(AdWordsUser), 'C:/OpenServer/d...')
#4 {main}
th in <b>C:\OpenServer\domains\googleads\Google\Api\Ads\AdWords\Util\v201607\ReportUtilsDelegate.php</b> on line <b>162</b><br />

вторник, 2 августа 2016 г., 11:02:29 UTC+3 пользователь adw...@prime-ltd.su написал:
Добрый день! напишите пожалуйста пример как можно получить остаток баланса на аккаунте adwords?

Michael Cloonan (AdWords API Team)

unread,
Sep 29, 2016, 9:00:14 AM9/29/16
to AdWords API Forum
Hello,

This error usually means that you're trying to run a report with your manager account, rather than with a client account. Reporting only works on the client account level; you can only report on a single account at a time.

Please try running the report on your client account and see if that resolves the issue.

Regards,
Mike, AdWords API Team
Reply all
Reply to author
Forward
0 new messages