我无法创建AdWords广告系列php

时间:2018-09-05 15:48:56

标签: php google-adwords

我正在尝试在php中创建一个Adwords广告系列,但出现此错误:

  

[AuthenticationError.OAUTH_TOKEN_INVALID @;触发:”]

我无法获得令牌。我尝试了很多事情,但没有成功。

这是我的代码:

 public static function main()
{
    try{

        $oauth2 = new OAuth2([
            'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
            'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
            'redirectUri' => 'http://php.a2hosted.com/google_adwords/index.php',
            'clientId' => '542903585223-i01068t4e2obim08dvs44u3p8da2boln.apps.googleusercontent.com',
            'clientSecret' => 'AIzaSyBOcsFeobRgkDVLhjFY04k7HiI1yVtnmY0',
            'scope' => 'https://www.googleapis.com/auth/adwords'
        ]);

        //$oauth2 = (new OAuth2TokenBuilder())->fromFile()->build();

        $authToken = $oauth2->setAccessToken( "ya29.GlsCBmAjyeVCK3Zkwp8zKxLN90dSmTlR0zRdH1--fDBgwLu6G8zrmTJr3GcyVpQ85UCd3n_vyEh3MOzo5dGnSqYpWwxLVC7j1Xq9ziDJLOHtEuRSuUYSPlHNDsR8" );
        //print_r( $oauth2 ); die;
        //return;
        // Construct an API session configured from a properties file and the
        // OAuth2 credentials above.
        $session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oauth2)->build();
        self::runExample(new AdWordsServices(), $session);
    }catch(Exception $e) { 
        echo $e->getMessage();
    }
}

我已包含所有库,但仍然出现令牌错误。
谁能帮助我解决此错误。

0 个答案:

没有答案