问题描述
我正在尝试SammyK / LaravelFacebookSdk。尝试从示例中运行此行:
$ response = Facebook :: get('/ me?fields = id,name,email','user-access-token' );
,依次运行 / var / www / vendor / facebook / php-sdk-v4 / src /Facebook/HttpClients/FacebookGuzzleHttpClient.php第61行
public function send($ url,$ method ,$ body,array $ headers,$ timeOut)
{
$ options = [
'headers'=> $ headers,
'body'=> $ body,
'timeout'=> $ timeOut,
'connect_timeout'=> 10,
'verify'=> __DIR__。 '/certs/DigiCertHighAssuranceEVRootCA.pem',
];
$ request = $ this-> guzzleClient-> createRequest($ method,$ url,$ options);
try {
$ rawResponse = $ this-> guzzleClient-> send($ request);
} catch(RequestException $ e){
$ rawResponse = $ e-> getResponse();
if($ e-> getPrevious()instanceof RingException ||!$ rawResponse instanceof ResponseInterface){
throw new FacebookSDKException($ e-> getMessage(),$ e-> ;引用代码());
}
}
$ rawHeaders = $ this-> getHeadersAsString($ rawResponse);
$ rawBody = $ rawResponse-> getBody();
$ httpStatusCode = $ rawResponse-> getStatusCode();
返回新的GraphRawResponse($ rawHeaders,$ rawBody,$ httpStatusCode);
}
调用 / var / www / vendor / guzzlehttp /guzzle/src/Client.php行87
public function __call($ method,$ args )
{
if(count($ args)< 1){
throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
}
$ uri = $ args [0];
$ opts = isset($ args [1])? $ args [1]:[];
return substr($ method,-5)==='Async'
? $ this-> requestAsync(substr($ method,0,-5),$ uri,$ opts)
:$ this-> request($ method,$ uri,$ opts);
}
将此输入解释为 array('method' =>'createRequest','uri'=>'GET'))
更改索引似乎纠正了错误问题araise)
$ uri = $ args [1];
$ opts = isset($ args [2])? $ args [2]:[];
但由于编辑其他软件包是一个非常糟糕的做法,应该如何更正此错误? p>
我也遇到同样的问题。
更改索引对我来说不起作用,但是我找到了一个解决方法。安装php-curl扩展通过cURL切换整个工作流程,所以问题消失了。
I'm experimenting with SammyK/LaravelFacebookSdk.Trying to run this line from example:$response = Facebook::get('/me?fields=id,name,email', 'user-access-token');
which in turn runs /var/www/vendor/facebook/php-sdk-v4/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php line 61
public function send($url, $method, $body, array $headers, $timeOut)
{
$options = [
'headers' => $headers,
'body' => $body,
'timeout' => $timeOut,
'connect_timeout' => 10,
'verify' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem',
];
$request = $this->guzzleClient->createRequest($method, $url, $options);
try {
$rawResponse = $this->guzzleClient->send($request);
} catch (RequestException $e) {
$rawResponse = $e->getResponse();
if ($e->getPrevious() instanceof RingException || !$rawResponse instanceof ResponseInterface) {
throw new FacebookSDKException($e->getMessage(), $e->getCode());
}
}
$rawHeaders = $this->getHeadersAsString($rawResponse);
$rawBody = $rawResponse->getBody();
$httpStatusCode = $rawResponse->getStatusCode();
return new GraphRawResponse($rawHeaders, $rawBody, $httpStatusCode);
}
That calls /var/www/vendor/guzzlehttp/guzzle/src/Client.php line 87
public function __call($method, $args)
{
if (count($args) < 1) {
throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
}
$uri = $args[0];
$opts = isset($args[1]) ? $args[1] : [];
return substr($method, -5) === 'Async'
? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
: $this->request($method, $uri, $opts);
}
This methond interprets input as array('method' => 'createRequest', 'uri' => 'GET'))
Changing index seems to correct the error (though other problems araise)
$uri = $args[1];
$opts = isset($args[2]) ? $args[2] : [];
But since it's a very bad practice to edit other packages, how should I correct this error?
I've get the same problem.Changing indexes won't work for me, but I've found a workaround. Installing php-curl extension switches a whole workflow thru cURL, so the problem is vanished.
这篇关于参数3传递给GuzzleHttp\Client :: request()必须是数组类型,给定字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!