Hi,

I have been  working on Google Adword API and am using PHP client sdk to 
request the SOAP call.
I have gone through the basic setup process.
I have created a Production MCC account and got a developer  Token from 
there which is pending from an email address.
So to test i created another Test MCC account using another email account.
>From this test MCC account , i created a test adword account which itself 
by default got linked, this got me my clientCustomerId
Now to get client id and client secret , I used the google console to 
create a project and create the client id. I used  Web Application Type to 
create the client id and put the redirection url 
to https://developers.google.com/oauthplayground
In the playground , i specified  client id , secret key in the setting and 
then the scope https://www.googleapis.com/auth/adwords to authorize, which 
got me the authorization code which then i exchanged to get referesh token 
 and access token.
Now when i use them in my file , till the time i access the user object , i 
get everything , but lets suppose i want to get a list of campaign then it 
shows the following error :

Fatal error: Uncaught SoapFault exception: [soap:Server] 
[AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'<null>'] in 
C:\wamp\www\googleAdwords\lib\Google\Api\Ads\Common\Lib\AdsSoapClient.php:231 
Stack trace: #0 
C:\wamp\www\googleAdwords\lib\Google\Api\Ads\Common\Lib\AdsSoapClient.php(231): 
SoapClient->__soapCall('get', Array, NULL, Array, Array) #1 
C:\wamp\www\googleAdwords\lib\Google\Api\Ads\AdWords\v201409\CampaignService.php(7777):
 
AdsSoapClient->__soapCall('get', Array) #2 
C:\wamp\www\googleAdwords\campaign.php(60): 
CampaignService->get(Object(Selector)) #3 {main} thrown in 
C:\wamp\www\googleAdwords\lib\Google\Api\Ads\Common\Lib\AdsSoapClient.php 
on line 231

Meanwhile , here is the code , with keys removed

<?php

$path = dirname(__FILE__) . '/lib'; 
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once dirname(__FILE__) . 
'/lib/Google/Api/Ads/AdWords/Lib/AdWordsUser.php'; 
require_once dirname(__FILE__) . 
'/lib/Google/Api/Ads/AdWords/Util/ReportUtils.php';


define("OAUTH_CLIENT_ID", "[****]");
define("OAUTH_CLIENT_SECRET", "[****]");
define("OAUTH_ACCESS_TOKEN", "[****]");
define("OAUTH_REFRESH_TOKEN", "[*****]");
define("CUSTOMER_ACCOUNT_ID", "[*****]");
define("DEVELOPER_TOKEN", "[****]");
define("API_VERSION", "v201409");
 
$user = new AdWordsUser();
$user->SetDeveloperToken(DEVELOPER_TOKEN);
$user->SetClientCustomerId(CUSTOMER_ACCOUNT_ID);

print_r($user); 

$user->SetOAuth2Info(array(
    "client_id" => OAUTH_CLIENT_ID,
    "client_secret" => OAUTH_CLIENT_SECRET,
    "access_token" => OAUTH_ACCESS_TOKEN,
    "refresh_token" => OAUTH_REFRESH_TOKEN
));
 
$user->LoadService('ReportDefinitionService', API_VERSION);
 
print_r($user);



// Get a list of campaigns
$campaignService = $user->GetService('CampaignService', API_VERSION);
$selector = new Selector();
$selector->fields = array('Id', 'Name');
$campaigns = $campaignService->get($selector);
 
print_r($campaigns);


?>


Please help me out !
I am not able to find a way out

Thanks
Abhishek Dutt

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/5d9ea7c7-4b05-48b2-8a94-834390305f96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to