Code Monkey home page Code Monkey logo

Comments (4)

ayushiindianic avatar ayushiindianic commented on June 14, 2024

Hi,

I'm Vergel Aranas. Currently use your package.

How to get all client/account customer Ids?

Could you find a way to get all clients/accounts? Please let me know. Thanks.

from laravel-google-ads.

iceverge avatar iceverge commented on June 14, 2024

Hi @ayushiindianic,

Yes, I've find a way to get all clients/accounts. Thanks for you package. It's really helpul.

from laravel-google-ads.

ayushiindianic avatar ayushiindianic commented on June 14, 2024

@iceverge
Haha that's not my package. I am also looking for a way to get all clients.
If you know please share the code if possible. Thanks!

from laravel-google-ads.

iceverge avatar iceverge commented on June 14, 2024

@ayushiindianic
here is the code.
Get all Account/Clients

`
public function getAllAccounts(Request $request)
{
$oAuth2Credential = $this->oAuth->userCredentials([
'clientId' => config('google-ads.production.clientId'),
'clientSecret' => config('google-ads.production.clientSecret'),
'refreshToken' => $request->refreshToken,
]);

$session = (new AdwordsSession())->buildWithOAuth(config('google-ads.production.developerToken'), $oAuth2Credential);
$managedCustomerService = (new AdWordsServices())->get($session, ManagedCustomerService::class);

$selector = (new Selector())
  ->setFields(['CustomerId', 'Name'])
  ->setOrdering([new OrderBy('CustomerId', SortOrder::ASCENDING)]);
$customers = $managedCustomerService->get($selector);

$clients = [];

foreach ($customers->getEntries() as $customer) {
  $clients[] = [
    'customer_name' => $customer->getName(),
    'customer_id' => $customer->getCustomerId()
  ];
}

return response($clients);

}
`

from laravel-google-ads.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.