/** * Download the given ProcessedImage sand save it to the given path. * * @param ProcessedImage $processedImage * @param string $savePath * @throws UnknownServerErrorException */ public function downloadProcessedImage(ProcessedImage $processedImage, $savePath) { $url = $processedImage->fileUrls[0]; if ($this->accessToken != null) { $url .= "?access_token=" . $this->accessToken->token(); } try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); $file = fopen($savePath, "w+"); fputs($file, $data); fclose($file); } catch (\Exception $e) { throw new UnknownServerErrorException("Failed to retrieve your image"); } }
public function __construct($clientId, $clientSecret, $accessToken, $expiresAt, array $scopes = []) { parent::__construct($clientId, $clientSecret, $accessToken, $expiresAt); $this->scopes = $scopes; }
public function __construct($clientId, $clientSecret, $accessToken, $expiresAt, $refreshToken) { parent::__construct($clientId, $clientSecret, $accessToken, $expiresAt); $this->refreshToken = $refreshToken; }