如何从laravelfacebooksdk增加超时,我收到错误:
[实\例外\ FacebookSDKException] 操作在0毫秒后超时,接收0个字节中的0个
请注意,我使用了包装层laravel facebook sdk
答案 0 :(得分:0)
我修改了这个文件以允许新的http_client_handler 我创建了一个新实例,并在此更新了htt_client_handler,更新了composer.json以读取Facebooksdk类。</ p>
composer.json
"autoload": {"classmap":
["database","/var/www/laravel/vendor/facebook/graph-sdk/src/Facebook"]
class xxx.php
class LongerTimeoutHttpClient extends
Facebook\HttpClients\FacebookStreamHttpClient
{public function send($url, $method, $body, array $headers, $timeOut){
$timeOut *= 4;
return parent::send($url, $method, $body, $headers, $timeOut);}}
public function handle(SammyK\LaravelFacebookSdk\LaravelFacebookSdk $fb)
{
$fbStream = new Facebook\HttpClients\FacebookStream;
$fb2 = $fb->newInstance([
'app_id' => env('FACEBOOK_APP_ID'),
'app_secret' => env('FACEBOOK_APP_SECRET'),
'default_graph_version' => 'v2.9',
'http_client_handler' => new LongerTimeoutHttpClient($fbStream),]);
}
通过这种方式,我允许实例$ fb。
中的值超时