代理后面的 Symfony HWI OAuth 登录错误

Symfony HWI OAuth login error behind a proxy

我正在使用带有 HWIOAuth Bundle 的 Symfony2 来登录 Facebook Google 和 twitter。当网络连接在代理登录后面时会出现以下错误

[2/2] HttpTransportException: Error while sending HTTP request
in vendor\hwi\oauth-bundle\OAuth\ResourceOwner\AbstractResourceOwner.php at line 258

[1/2] RequestException: Connection timed out after 5000 milliseconds
in vendor\kriswallsmith\buzz\lib\Buzz\Client\Curl.php at line 29

HWIOAuthBundle 依赖于 Buzz,后者使用 php cURL 发送请求。所以你需要为 cURL 设置代理。由于 symfony 框架,我们可以在不弄脏手的情况下做到这一点。就像在 app/config/config.yml 中添加一个新行一样简单,如下所示。

# app/config/config.yml 
hwi_oauth:
     http_client:
         proxy: "example.com:8080"   # String with proxy configuration for cURL connections, ignored by default.
                                     # "" -> don't set proxy and will use proxy system
                                     # "example.com:8080" -> set custom proxy
                                     # ":" -> disable proxy usage, ignoring also proxy system and ENVIRONMENT variables

configuring_the_http_client.md