Pedro Chagas
asked on
What is the client_email, developer_token, useragent and application_token in adword api?
Hi, I try learn more about google API and I get the code you see in code snippet for I made a test and closer to the tool.
I have doubts about this part of the code:
$email = 'INSERT_LOGIN_EMAIL_HERE';
$password = 'INSERT_PASSWORD_HERE';
$client_email = 'INSERT_CLIENT_LOGIN_EMAIL _HERE';
$useragent = 'INSERT_COMPANY_NAME: AdWords API PHP Sample Code';
$developer_token = 'INSERT_DEVELOPER_TOKEN_HE RE';
$application_token = 'INSERT_APPLICATION_TOKEN_ HERE';
I have account in google adwords. So email and password can be the same I use for login in my adwords account, right?
The client_email is the same of my e-mail?
How I get useragent, developer_token and application_token.
Regards, JC
I have doubts about this part of the code:
$email = 'INSERT_LOGIN_EMAIL_HERE';
$password = 'INSERT_PASSWORD_HERE';
$client_email = 'INSERT_CLIENT_LOGIN_EMAIL
$useragent = 'INSERT_COMPANY_NAME: AdWords API PHP Sample Code';
$developer_token = 'INSERT_DEVELOPER_TOKEN_HE
$application_token = 'INSERT_APPLICATION_TOKEN_
I have account in google adwords. So email and password can be the same I use for login in my adwords account, right?
The client_email is the same of my e-mail?
How I get useragent, developer_token and application_token.
Regards, JC
<?php
// Copyright 2008, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/** This code sample retrieves variations for a seed keyword. */
require_once('soapclientfactory.php');
# Provide AdWords login information.
$email = 'INSERT_LOGIN_EMAIL_HERE';
$password = 'INSERT_PASSWORD_HERE';
$client_email = 'INSERT_CLIENT_LOGIN_EMAIL_HERE';
$useragent = 'INSERT_COMPANY_NAME: AdWords API PHP Sample Code';
$developer_token = 'INSERT_DEVELOPER_TOKEN_HERE';
$application_token = 'INSERT_APPLICATION_TOKEN_HERE';
# Define SOAP headers.
$headers =
'<email>' . $email . '</email>'.
'<password>' . $password . '</password>' .
'<clientEmail>' . $client_email . '</clientEmail>' .
'<useragent>' . $useragent . '</useragent>' .
'<developerToken>' . $developer_token . '</developerToken>' .
'<applicationToken>' . $application_token . '</applicationToken>';
# Set up service connection. To view XML request/response, change value of
# $debug to 1. To send requests to production environment, replace
# "sandbox.google.com" with "adwords.google.com".
$namespace = 'https://sandbox.google.com/api/adwords/v12';
$keyword_tool_service = SoapClientFactory::GetClient(
$namespace . '/KeywordToolService?wsdl', 'wsdl');
$keyword_tool_service->setHeaders($headers);
$debug = 0;
# Create seed keyword structure.
$seed_keyword =
'<negative>false</negative>' .
'<text>mars cruise</text>' .
'<type>Broad</type>';
$use_synonyms = '<useSynonyms>true</useSynonyms>';
# Get keyword variations.
$request_xml =
'<getKeywordVariations>' .
'<seedKeywords>' . $seed_keyword . '</seedKeywords>' .
$use_synonyms .
'<languages>en</languages>' .
'<countries>US</countries>' .
'</getKeywordVariations>';
$variation_lists =
$keyword_tool_service->call('getKeywordVariations', $request_xml);
$variation_lists = $variation_lists['getKeywordVariationsReturn'];
if ($debug) show_xml($keyword_tool_service);
if ($keyword_tool_service->fault) show_fault($keyword_tool_service);
# Display keyword variations.
$to_consider = $variation_lists['additionalToConsider'];
echo 'List of additional keywords to consider has ' . count($to_consider) .
' variation(s).' . "\n";
$more_specific = $variation_lists['moreSpecific'];
echo 'List of popular queries with given seed has ' . count($more_specific) .
' variation(s).' . "\n";
function show_xml($service) {
echo $service->request;
echo $service->response;
echo "\n";
}
function show_fault($service) {
echo "\n";
echo 'Fault: ' . $service->fault . "\n";
echo 'Code: ' . $service->faultcode . "\n";
echo 'String: ' . $service->faultstring . "\n";
echo 'Detail: ' . $service->faultdetail . "\n";
exit(0);
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.