Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there any plans to add a proxy option to this? #119

Open
nemuki opened this issue Aug 27, 2021 · 0 comments
Open

Are there any plans to add a proxy option to this? #119

nemuki opened this issue Aug 27, 2021 · 0 comments

Comments

@nemuki
Copy link

nemuki commented Aug 27, 2021

Hi

Problems

My school has a proxy server, and when I try to use this library there, I get the following error.

PHP Fatal error:  Uncaught GuzzleHttp\\Exception\\ConnectException: cURL error 28: Failed to connect to api.unsplash.com port 443: Connection timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.unsplash.com/photos/random?query=snow&w=600&h=400

In the .bashrc, I have written http_proxy and https_proxy, and when I access the API with cURL in the CLI, I can access it successfully.

Solved method

I was able to solve this problem by adding a proxy option to __construct() in HttpClient.php, referring to the Guzzle document.

$this->httpClient = new Client(['handler' => $this->setHandler(self::$connection->getAuthorizationToken()), 'proxy' => 'http://hostname:port');

I don't know much about PHP, so I can't modify the code and submit a pull request.
I would like to know if there is a way to add a proxy option to this library or any other way to solve this problem.
I'm sorry for my poor English.

Development Environment

  • Ubuntu Server 20.04
  • PHP 7.4
  • Apache 2.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant