Hi there,

After having loads of suggestions from you guys I solved my problems. 
However there is one thing left.
Before I begin I will add my code here so anyone can see and get an idea.

Please note; I am trying to avoid using .ini file and create this as user 
authenticates with the application. I am getting my RefreshToken then I am 
trying to get the ClientCustomerId to be able to fetch the campaigns.

require 'vendor/autoload.php';
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201609\cm\CampaignService;
use Google\AdsApi\AdWords\v201609\cm\OrderBy;
use Google\AdsApi\AdWords\v201609\cm\Paging;
use Google\AdsApi\AdWords\v201609\cm\Selector;
use Google\AdsApi\Common\OAuth2TokenBuilder;
use Google\AdsApi\AdWords\v201609\mcm\CustomerService;
session_start();
$clientId = "*****";
$clientSecret = "****";
if(isset($_SESSION['refreshToken'])){
    $refreshToken =  $_SESSION['refreshToken'];
}else{
    $refreshToken = NULL;
}


$oAuth2Credential = (new OAuth2TokenBuilder())
    ->withClientId($clientId)
    ->withClientSecret($clientSecret)
    ->withRefreshToken($refreshToken)
    ->build();


The trick was removing ->fromFile() and adding withClientId, 
withClientSecret and withRefreshToken.

All good now!  The last missing puzzle is how to optain ClientCustomerId. 

$session = (new AdWordsSessionBuilder())    
    ->withClientCustomerId($clientCustomerId)
    ->withOAuth2Credential($oAuth2Credential)
    ->build();


I tried to get it like this;

$customerService = new CustomerService();
$cliendData = $customerService->getCustomers();


*However I am facing with the following error.*
*Fatal error: Call to a member function generateHttpHeaders() on null in 
/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php 
on line 86*

Can you put me in a right direction? Because as far as I understand from 
the docs here 
<https://developers.google.com/adwords/api/docs/reference/v201609/CustomerService#getcustomers>
 
getCustomers does not require any parameters.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/99372b7d-fe08-43af-beea-690ddaed3700%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to