【发布时间】:2016-05-11 11:31:55
【问题描述】:
我正在试验 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 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);
}
调用/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);
}
此方法将输入解释为array('method' => 'createRequest', 'uri' => 'GET'))
更改索引似乎可以纠正错误(尽管会出现其他问题)
$uri = $args[1];
$opts = isset($args[2]) ? $args[2] : [];
但是由于编辑其他包是一种非常糟糕的做法,我应该如何纠正这个错误?
【问题讨论】:
-
您好 Edmund,不确定您是否已经找到了解决方案?我在这里遇到了同样的问题:(
-
@KeithYeoh 我放弃了插件,要么自己编写代码,要么使用 Socialte(laravel 官方插件)+一些自定义代码。我真的不记得了。我只记得我的解决方案比插件更干净、更简单的感觉
标签: php facebook facebook-graph-api laravel-5.2