Пример #1
0
 /**
  * @param GoogleHelper $helper
  */
 public function __construct(GoogleHelper $helper)
 {
     $this->helper = $helper;
     $client = $helper->getClient();
     $client->setScopes(array('https://www.googleapis.com/auth/drive'));
     $this->service = new \Google_Service_Drive($client);
 }
Пример #2
0
 public function __construct($settings = array())
 {
     if (!isset($settings['clientId'])) {
         throw new BackupException('clientId not provided');
     }
     if (!isset($settings['clientSecret'])) {
         throw new BackupException('clientSecret not provided');
     }
     if (isset($settings['accessTokenLocation'])) {
         $this->accessTokenLocation = $settings['accessTokenLocation'];
     }
     if (isset($settings['refreshTokenLocation'])) {
         $this->refreshTokenLocation = $settings['refreshTokenLocation'];
     }
     $googleHelper = new GoogleHelper($settings['clientId'], $settings['clientSecret']);
     $this->filesHelper = new FilesHelper($googleHelper);
     if (file_exists($this->accessTokenLocation)) {
         $googleHelper->setAccessToken(file_get_contents($this->accessTokenLocation));
     }
     if (file_exists($this->refreshTokenLocation)) {
         $googleHelper->setRefreshToken(file_get_contents($this->refreshTokenLocation));
     }
     $googleHelper->auth(GoogleHelper::AUTH_TYPE_CMD_LINE);
     // Save access and refresh tokens
     file_put_contents($this->accessTokenLocation, $googleHelper->getAccessToken());
     file_put_contents($this->refreshTokenLocation, $googleHelper->getRefreshToken());
     $this->baseFolder = $this->filesHelper->getFolderByName($this->baseFolderName, false, null, true);
 }
Пример #3
0
 /**
  * @param GoogleHelper $helper
  */
 public function __construct(GoogleHelper $helper)
 {
     $helper->getClient()->addScope('https://apps-apis.google.com/a/feeds/emailsettings/');
     $this->helper = $helper;
 }