function onNextendYoutube(&$google, &$youtube) { $config = new NextendData(); $config->loadJson(NextendSmartSliderStorage::get(self::$_group)); if (!class_exists('Google_Client')) { require_once dirname(__FILE__) . '/googleclient/Google_Client.php'; } if (!class_exists('Google_YouTubeService')) { require_once dirname(__FILE__) . '/googleclient/contrib/Google_YouTubeService.php'; } $google = new Google_Client(); $google->setClientId($config->get('apikey', '')); $google->setClientSecret($config->get('apisecret', '')); $token = $config->get('token', null); if ($token) { $google->setAccessToken($token); } $youtube = new Google_YouTubeService($google); if ($google->isAccessTokenExpired()) { $token = json_decode($google->getAccessToken(), true); if (isset($token['refresh_token'])) { $google->refreshToken($token['refresh_token']); $config->set('token', $google->getAccessToken()); NextendSmartSliderStorage::set(self::$_group, $config->toJSON()); } } }