1 | <?php |
||
15 | class Facebook |
||
16 | { |
||
17 | /** @var HttpClient HTTP Client */ |
||
18 | protected $http; |
||
19 | |||
20 | /** @var string|null Page Token. */ |
||
21 | protected $token; |
||
22 | |||
23 | /** @var string|null App Secret */ |
||
24 | protected $secret; |
||
25 | |||
26 | /** @var string Default Graph API Version */ |
||
27 | protected $graphApiVersion = '4.0'; |
||
28 | |||
29 | /** |
||
30 | * @param string|null $token |
||
31 | * @param HttpClient|null $httpClient |
||
32 | */ |
||
33 | public function __construct(string $token = null, HttpClient $httpClient = null) |
||
39 | |||
40 | /** |
||
41 | * Set Default Graph API Version. |
||
42 | * |
||
43 | * @param $graphApiVersion |
||
44 | * |
||
45 | * @return Facebook |
||
46 | */ |
||
47 | public function setGraphApiVersion($graphApiVersion): self |
||
53 | |||
54 | /** |
||
55 | * Set App Secret to generate appsecret_proof. |
||
56 | * |
||
57 | * @param string $secret |
||
58 | * |
||
59 | * @return Facebook |
||
60 | */ |
||
61 | public function setSecret($secret = null): self |
||
67 | |||
68 | /** |
||
69 | * Get HttpClient. |
||
70 | * |
||
71 | * @return HttpClient |
||
72 | */ |
||
73 | protected function httpClient(): HttpClient |
||
77 | |||
78 | /** |
||
79 | * Send text message. |
||
80 | * |
||
81 | * @param array $params |
||
82 | * |
||
83 | * @throws GuzzleException |
||
84 | * @throws CouldNotSendNotification |
||
85 | * @return ResponseInterface |
||
86 | */ |
||
87 | public function send(array $params): ResponseInterface |
||
91 | |||
92 | /** |
||
93 | * @param string $endpoint |
||
94 | * @param array $params |
||
95 | * |
||
96 | * @throws GuzzleException |
||
97 | * @throws CouldNotSendNotification |
||
98 | * @return ResponseInterface |
||
99 | */ |
||
100 | public function get(string $endpoint, array $params = []): ResponseInterface |
||
104 | |||
105 | /** |
||
106 | * @param string $endpoint |
||
107 | * @param array $params |
||
108 | * |
||
109 | * @throws GuzzleException |
||
110 | * @throws CouldNotSendNotification |
||
111 | * @return ResponseInterface |
||
112 | */ |
||
113 | public function post(string $endpoint, array $params = []): ResponseInterface |
||
117 | |||
118 | /** |
||
119 | * Send an API request and return response. |
||
120 | * |
||
121 | * @param string $endpoint |
||
122 | * @param array $options |
||
123 | * @param string $method |
||
124 | * |
||
125 | * @throws GuzzleException |
||
126 | * @throws CouldNotSendNotification |
||
127 | * @return mixed|ResponseInterface |
||
128 | */ |
||
129 | protected function api(string $endpoint, array $options, $method = 'GET') |
||
151 | } |
||
152 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: