Google AdWords API-无法从@gmail

时间:2019-02-15 20:37:22

标签: php google-adwords

我正在尝试从MCC帐户(以及从MCC帐户先前授予访问权限的另一个帐户)中提取帐户,但响应为空。

特殊事项:

  1. 这些帐户(MCC和另一个具有管理员权限的帐户)是@ gmail.com(不是另一个私有域)。

  2. 我已连接另一个帐户,没有任何问题(使用相同的AdWords应用程序/凭据/等)。

  3. 我正在使用的PHP代码如下所示。

我是否需要任何特殊的配置/其他设置?提取帐户失败有什么原因?

    $sessionToken = 
  array (
    'access_token' => 'XXX',
    'expires_in' => 3600,
    'refresh_token' => 'YYY',
    'scope' => 'https://www.googleapis.com/auth/userinfo.email openid https://www.googleapis.com/auth/adwords',
    'token_type' => 'Bearer',
    'id_token' => 'ZZZ',
  );

        $client = [];
        $client['developer_token'] = ::GOOGLE_DISPLAY_TOKEN::;
        $client['master_client_id'] = ::GOOGLE_DISPLAY_MASTER_CLIENT_ID::;
        $client['master_client_secret'] = ::GOOGLE_DISPLAY_MASTER_CLIENT_SECRET::;
        $client['refresh_token'] = $sessionToken['refresh_token'];
        $client['token'] = $sessionToken['token'];

        $oAuth2Credential = (new OAuth2TokenBuilder())
            ->withClientId($client['master_client_id'])
            ->withClientSecret($client['master_client_secret'])
            ->withRefreshToken($client['refresh_token'])
            ->build();

        $session = (new AdWordsSessionBuilder())
            ->withDeveloperToken($client['developer_token'])
            ->withOAuth2Credential($oAuth2Credential)
            ->build();

        $managedCustomerService = (new AdWordsServices())->get($session, ManagedCustomerService::class);
        $selector = new Selector();
        $selector->setFields(['CustomerId', 'Name', 'canManageClients']);
        $page = $managedCustomerService->get($selector);
        dump($page->getEntries());
        die;

0 个答案:

没有答案