PHP为什么我在回显时得到相同的值?

PHP为什么我在回显时得到相同的值?,php,yii,google-analytics,Php,Yii,Google Analytics,这是因为我使用了同一个类吗?就像谷歌新客户端的代码一样。但是我不确定我是否用正确的方法做了。有什么想法吗?谢谢 如您在 它在静态字段中存储值。谢谢!我是否应该修改源代码,或者在不修改Google_客户端源代码核心的情况下,有一个更简单的方法。唯一的方法是首先使用客户端,然后使用youtubeClient(如果可能的话)。 public $client; public $youtubeClient; public function init() {

这是因为我使用了同一个类吗?就像谷歌新客户端的代码一样。但是我不确定我是否用正确的方法做了。有什么想法吗?谢谢

如您在


它在静态字段中存储值。

谢谢!我是否应该修改源代码,或者在不修改Google_客户端源代码核心的情况下,有一个更简单的方法。唯一的方法是首先使用客户端,然后使用youtubeClient(如果可能的话)。
    public $client;
    public $youtubeClient;

    public function init()
    {
        Yii::import('ext.googleapi.src.*');
        require_once 'Google_Client.php';
        require_once 'contrib/Google_AnalyticsService.php';

        $this->client = new Google_Client();
        $this->client->setApplicationName(Yii::app()->params['applicationName']);

        $this->client->setClientId(Yii::app()->params['client_id']);
        $this->client->setClientSecret(Yii::app()->params['client_secret']);
        $this->client->setRedirectUri(Yii::app()->params['redirect_uri']);
        $this->client->setDeveloperKey(Yii::app()->params['developer_key']);
        $this->client->setScopes(array(Yii::app()->params['scopes']));
        $this->client->setUseObjects(true);

    /*** Youtube Connect Code ***/
    require_once 'contrib/Google_YouTubeAnalyticsService.php';
    require_once 'contrib/Google_YouTubeService.php';

    $this->youtubeClient = new Google_Client();
    $this->youtubeClient->setClientId(Yii::app()->params['youtube_client_id']);
    $this->youtubeClient->setClientSecret(Yii::app()->params['youtube_client_secret']);
    $this->youtubeClient->setScopes(array(
      'https://www.googleapis.com/auth/yt-analytics.readonly',
      'https://www.googleapis.com/auth/youtube.readonly'
    ));
    $this->youtubeClient->setDeveloperKey(Yii::app()->params['developer_key']);
    $redirect = filter_var(Yii::app()->params['youtube_redirect_uri'],FILTER_SANITIZE_URL);
    $this->youtubeClient->setRedirectUri($redirect);
    $this->youtubeClient->setState(mt_rand());
    $this->youtubeClient->setUseObjects(true);

    echo "Client Secret: ".$this->client->getClientSecret();
    echo "<br>";
    echo "Youtube Secret: ".$this->youtubeClient->getClientSecret();
    die;
  }
Client Secret: aaaa-bbb-ccc
Youtube Secret: aaa-bbb-ccc
public function setClientSecret($clientSecret) {
    global $apiConfig;
    $apiConfig['oauth2_client_secret'] = $clientSecret;
    self::$auth->clientSecret = $clientSecret;
}