2
votes

I have my code repo on a dev box and when I moved it to prod box, it was not able to make complete the FB calls. My error is:

ErrorException in Client.php line 126: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /var/www/mypopshare.com/vendor/guzzlehttp/guzzle/src/Client.php on line 87 and defined

My code for this section is: return substr($method, -5) === 'Async' ? $this->requestAsync(substr($method, 0, -5), $uri, $opts) : $this->request($method, $uri, $opts);

The library on both servers is installed via composer: `

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "illuminate/html": "^5.0",
    "laravelcollective/html": "^5.2",
    "league/flysystem-aws-s3-v3": "~1.0",
    "webpatser/laravel-uuid": "^2.0",
    "intervention/image": "^2.3",
    "doctrine/dbal": "^2.5",
    "guzzlehttp/guzzle": "^6.1",
    "sammyk/laravel-facebook-sdk": "^3.3"
},

`

That is the same on both environments and have done composer install to make sure they are there.

The call is being made from the Facebook PHP SDK via the sammk/laravel-facebook-sdk package. My only guess is some other configuration difference on the servers, but not sure where to check. I did not configure the prod server. Any suggestions are appreciated.

2
Having the exact same issue. Can't figure out what is causing it. I'm using the Facebook's official composer package, so I don't think it is being caused by the Laravel wrapper. I'm running the exact same (php7) version on both servers. My code in the stack trace is: Facebook\Facebook->get()Boyd
I'm also having the exact same issue, but using the Facebook SDK directly without SammyK's wrapper. It works on my development server (the latest Homestead using php7) but fails on production. Has anyone found a solution other than telling the FB SDK to instead use curl?mmccaff

2 Answers

4
votes

FYI - I found a solution that is similar to the current answer. I was using the Facebook SDK directly without SammyK's wrapper and was not explicitly setting a http_client_handler.

It turns out, if the curl extension is not installed, the Facebook SDK falls back on Guzzle but uses Guzzle 5 syntax. I had Guzzle 6 installed, so got this error because the arguments have changed.

The fix for me was to install php7.0-curl. On Ubuntu 14.04 LTS, this was:

sudo apt-get install php7.0-curl

The Facebook SDK then used curl which did not get this error and I did not have to update any existing code to explicitly set a http_client_handler.

This worked on dev which had the php-curl extension installed and failed on prod when it did not. You can see your list of installed extensions to confirm:

php -m
2
votes

I had the same issue on Ubuntu 16.04 with php7.0. if guzzle is not a requirement in your project, you can consider switching facebook_config's http_client_handler option of sammk/laravel-facebook-sdk package config file to curl.

'facebook_config' => [
    'app_id' => env('FACEBOOK_APP_ID'),
    'app_secret' => env('FACEBOOK_APP_SECRET'),
    'default_graph_version' => 'v2.6',
    //'enable_beta_mode' => true,
    'http_client_handler' => 'curl',
],