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 getCustomers does not require any parameters.