Google ads api —— github

https://developers.google.com/google-ads/api/docs/client-libs

Client Libraries

Our client libraries provide high-level views and basic building blocks of Google Ads API functionality, making it easier to develop apps quickly. We recommend starting out with one if you're new to the API.

Client librarySourceDistributionCode examples
Java google-ads-java Maven, tar.gz View on GitHub
.NET google-ads-dotnet tar.gz, zip View on GitHub
PHP google-ads-php tar.gz View on GitHub
Python google-ads-python tar.gz, zip View on GitHub
Ruby google-ads-ruby gem, tar.gz, zip View on GitHub
Perl google-ads-perl tar.gz, zip View on GitHub

 https://github.com/googleads/google-ads-dotnet

Configuration

Each Ads API Client library provides different configuration settings and loading methods that you can use to customize its behavior.

Here are the environment variables that are common to all client libraries and that can be loaded to set configuration settings:

  • Client library
    • GOOGLE_ADS_CONFIGURATION_FILE_PATH: Path to the configuration file.
  • OAuth2
    • Application Mode
      • GOOGLE_ADS_CLIENT_ID : Set this value to your OAuth2 client ID.
      • GOOGLE_ADS_CLIENT_SECRET : Set this value to your OAuth2 client secret.
      • GOOGLE_ADS_REFRESH_TOKEN : Set this value to a pre-generated OAuth2 refresh token if you want to reuse OAuth2 tokens. This setting is optional.
    • Service Account Mode
      • GOOGLE_ADS_JSON_KEY_FILE_PATH : Set this value to the OAuth2 JSON configuration file path.
      • GOOGLE_ADS_IMPERSONATED_EMAIL : Set this value to the email address of the account you are impersonating.
  • Google Ads API
    • GOOGLE_ADS_DEVELOPER_TOKEN : Set this to your developer token.
    • GOOGLE_ADS_LOGIN_CUSTOMER_ID : This is the customer ID of the authorized customer to use in the request, without hyphens (-).
    • GOOGLE_ADS_LINKED_CUSTOMER_ID : This header is only required for methods that update the resources of an entity when permissioned through Linked Accounts in the Google Ads UI (AccountLink resource in the Google Ads API). Set this value to the customer ID of the data provider that updates the resources of the specified customer ID. It should be set without hyphens (-). To learn more about Linked Accounts, visit the Help Center.

Note: For more detail on how to use them and any additional client library-specific environment variables, refer to the configuration guides that are dedicated to each client library: Java, .NET, PHP, Python, Ruby, Perl.

Environment variables are commonly defined in a bash configuration file such as a .bashrc or .bash_profile file located in the $HOME directory. They can also be defined using the command line.

Note: These instructions assume you're using Bash. If you're using a different shell, consult documentation for equivalent commands.

Here are some basic steps to define an environment variable using a .bashrc file using a terminal:

 
# Append the line "export GOOGLE_ADS_CLIENT_ID=1234567890" to
# the bottom of your .bashrc file.
echo "export GOOGLE_ADS_CLIENT_ID=1234567890" >> ~/.bashrc

# Update your bash environment to use the most recently updated
# version of your .bashrc file.
src ~/.bashrc

Environment variables can also be set in your terminal instance directly from the command line:

 
export GOOGLE_ADS_CLIENT_ID=1234567890

Another alternative is to set environment variables when calling the command that uses them:

 
GOOGLE_ADS_CLIENT_ID=1234567890 php /path/to/script/that/uses/envvar.php

Diagnostic tool

Google Ads Doctor analyzes your client library environment by

  • verifying your OAuth2 credentials with Google Ads API.
  • guiding you through fixing any OAuth2 problems in your configuration file.

Code examples

Check out our code examples of some common functions in the Google Ads API.

The .NET Client Library

The .NET client library is hosted at github.com/googleads/google-ads-dotnet, and is distributed as a NuGet package on nuget.org.

The library supports requires .NET Framework 4.7.2+ (net472) when using .NET Framework, or .NET Standard 2.0 (netstandard2.0) when using .NET Core. The code example binaries target .NET Core 3.0 (netcoreapp3.0). To use this library, you will need the information listed in Prerequisites.

See Getting started to start using this library.

To get OAuth2 refresh tokens, visit the following guides:

To make API calls using OAuth2 service accounts, visit the OAuth service account flow guide.

Visit the following guides for the library's features and utilities:

Features

  • Stub classes for all the supported API versions and services.
  • Easy management of credentials, authentication, and session information.
  • Docs available in HTML and XML format.

 

Supported Frameworks

  • .NET Framework 4.7.2+ (net472)
  • .NET Standard 2.0 (netstandard2.0)
  • .NET Core 3.0 (netcoreapp3.0)

 

 

 

https://github.com/googleads/google-ads-dotnet/tree/86eefe5a710abde9e0008325569a348ac5f90402

Documentation

Our documentation is available here.

 

Miscellaneous

 

Wiki

 

Issue tracker

 

API Documentation

 

Support forum

 

Authors

 
原文地址:https://www.cnblogs.com/panpanwelcome/p/15793326.html