Google adwords API

Source: Internet
Author: User
Tags email account adwords api

Google adwords APIs are divided into formal APIs and test APIs.

Official APIs in the base layer are charged, and Google charges fees based on the API unit. In the test API (sandbox), no fees are charged, but some APIs return results defined by Google, not a good test! Google is also the recently released v13 version. It used to be V12. Because my email account is a non-paid account, you cannot use the official API to debug the service. After recharge, Google will deduct 50 items first!

For example, two types of APIs are referenced in a project:

    • Formal API

URL: https://adwords.google.com/api/adwords/v13/AccountService? WSDL

Reference name: googleadwords. accountservice

    • Test API

URL: https://sandbox.google.com/api/adwords/v13/AccountService? WSDL

Reference name: googleadwords. sandbox. accountservice

CodeAs shown in the following figure, the following errors will occur during the test respectively:

Code
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. text;

UsingSystem. Web;

// Formal API
Using Gae. Cl. googleadwords. accountservice;
// Test API
// Using Gae. Cl. googleadwords. sandbox. accountservice;

Namespace Gae. Cl. classlibrary
{
Public   Class Main
{
# Region Constant
Private   Static   String Email =   " Itblackhole@gmail.com " ;
Private   Static   String Password =   " ****** " ;
Private   Static   String Useragent =   " Insert_company_name: adwords api dotnet sample code " ;
Private   Static   String Token token =   " Itblackhole@gmail.com ++ CNY " ;
Private   Static   String Applicationtoken =   " Insert_application_token_here " ;
# Endregion Constant

Public   Void Getclientaccounts ( Out   String [] Customerclientemail)
{
Customerclientemail =   Null ;
Try
{
// Set up service connection.
Accountservice Service =   New Accountservice ();

// Define SOAP Headers.
Service. emailvalue =   New Email ();
Service. emailvalue. Text =   New String [] {email };
Service. passwordvalue =   New Password ();
Service. passwordvalue. Text =   New String [] {password };
Service. useragentvalue =   New Useragent ();
Service. useragentvalue. Text =   New String [] {useragent };
Service. Define tokenvalue =   New Token token ();
Service. Define tokenvalue. Text =   New String [] {token };
Service. applicationtokenvalue =   New Applicationtoken ();
Service. applicationtokenvalue. Text =   New String [] {applicationtoken };

//Get client accounts.
String[] Loginemails=Service. getclientaccounts ();

// Display login emails.
If (Loginemails ! =   Null )
{
Customerclientemail = Loginemails;
Foreach ( String Customeremail In Loginemails)
{
Httpcontext. Current. response. Write ( " Login email is \ "" + Customeremail + " \ " . <Br/> " );
}
}
Else
{
Httpcontext. Current. response. Write ( " Header element to be used when the "my customer center" (MCC) account modifies the customer account. <Br/> " );
}

}
Catch(Exception E)
{
Httpcontext. Current. response. Write (E. tostring ()+ "<Br/>");
}
}
}
}

 

If you use a formal API to run the above Code, an "invalid developer token" will be reported, for example, system. Web. Services. Protocols. soapexception: The developer token is invalid.

If you run the test API, the following information is returned correctly:

Login email is "client_1 + itblackhole@gmail.com ".
Login email is "client_2 + itblackhole@gmail.com ".
Login email is "client_3 + itblackhole@gmail.com ".
Login email is "client_4 + itblackhole@gmail.com ".
Login email is "client_5 + itblackhole@gmail.com ".

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.