Google\Spreadsheet\DefaultServiceRequest::__construct PHP Method

__construct() public method

Initializes the service request object.
public __construct ( string $accessToken, string $tokenType = "OAuth" )
$accessToken string
$tokenType string
    public function __construct($accessToken, $tokenType = "OAuth")
    {
        $this->accessToken = $accessToken;
        $this->tokenType = $tokenType;
    }

Usage Example

 /**
  * set google client
  *
  * @param string $scope
  * @param string $clientEmail
  * @param string $privateKeyFile
  */
 public function __construct($scope, $clientEmail, $privateKeyFile)
 {
     if (!file_exists($privateKeyFile)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $privateKeyFile));
     }
     $privateKey = file_get_contents($privateKeyFile);
     $credentials = new Google_Auth_AssertionCredentials($clientEmail, array($scope), $privateKey);
     $this->client = new Google_Client();
     $this->client->setAssertionCredentials($credentials);
     parent::__construct('');
 }