1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2017 Facebook, Inc. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
namespace Facebook\HttpClients; |
25
|
|
|
|
26
|
|
|
use Facebook\Http\GraphRawResponse; |
27
|
|
|
use Facebook\Exceptions\FacebookSDKException; |
28
|
|
|
|
29
|
|
|
use GuzzleHttp\Client; |
30
|
|
|
use GuzzleHttp\Psr7\Request; |
|
|
|
|
31
|
|
|
use GuzzleHttp\Message\ResponseInterface; |
32
|
|
|
use GuzzleHttp\Ring\Exception\RingException; |
33
|
|
|
use GuzzleHttp\Exception\RequestException; |
34
|
|
|
|
35
|
|
|
class FacebookGuzzleHttpClient implements FacebookHttpClientInterface |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @var \GuzzleHttp\Client The Guzzle client. |
39
|
|
|
*/ |
40
|
|
|
protected $guzzleClient; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param \GuzzleHttp\Client|null The Guzzle client. |
|
|
|
|
44
|
|
|
*/ |
45
|
|
|
public function __construct() |
46
|
|
|
{ |
47
|
|
|
$this->guzzleClient = new Client(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritdoc |
52
|
|
|
*/ |
53
|
|
|
public function send($url, $method, $body, array $headers, $timeOut) |
54
|
|
|
{ |
55
|
|
|
$request = new Request($method, $url, $headers, $body); |
56
|
|
|
|
57
|
|
|
try { |
58
|
|
|
$response = $this->guzzleClient->send($request, ['timeout' => $timeOut, 'http_errors' => false]); |
|
|
|
|
59
|
|
|
} catch (GuzzleHttp\Exception\RequestException $e) { |
|
|
|
|
60
|
|
|
throw new FacebookSDKException($e->getMessage(), $e->getCode()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$httpStatusCode = $response->getStatusCode(); |
|
|
|
|
64
|
|
|
$responseHeaders = $response->getHeaders(); |
|
|
|
|
65
|
|
|
foreach ($responseHeaders as $key => $values) { |
66
|
|
|
$responseHeaders[$key] = implode(', ', $values); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$responseBody = $response->getBody()->getContents(); |
|
|
|
|
70
|
|
|
|
71
|
|
|
return new GraphRawResponse( |
72
|
|
|
$responseHeaders, |
73
|
|
|
$responseBody, |
74
|
|
|
$httpStatusCode |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths