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 Default Graph API Version */ |
||
24 | protected $graphApiVersion = '4.0'; |
||
25 | |||
26 | /** |
||
27 | * @param string|null $token |
||
28 | * @param HttpClient|null $httpClient |
||
29 | */ |
||
30 | public function __construct(string $token = null, HttpClient $httpClient = null) |
||
36 | |||
37 | /** |
||
38 | * Set Default Graph API Version. |
||
39 | * |
||
40 | * @param $graphApiVersion |
||
41 | * |
||
42 | * @return Facebook |
||
43 | */ |
||
44 | public function setGraphApiVersion($graphApiVersion): Facebook |
||
50 | |||
51 | /** |
||
52 | * Get HttpClient. |
||
53 | * |
||
54 | * @return HttpClient |
||
55 | */ |
||
56 | protected function httpClient(): HttpClient |
||
60 | |||
61 | /** |
||
62 | * Send text message. |
||
63 | * |
||
64 | * @param array $params |
||
65 | * |
||
66 | * @throws GuzzleException |
||
67 | * @throws CouldNotSendNotification |
||
68 | * @return ResponseInterface |
||
69 | */ |
||
70 | public function send(array $params): ResponseInterface |
||
74 | |||
75 | /** |
||
76 | * @param string $endpoint |
||
77 | * @param array $params |
||
78 | * |
||
79 | * @throws GuzzleException |
||
80 | * @throws CouldNotSendNotification |
||
81 | * @return ResponseInterface |
||
82 | */ |
||
83 | public function get(string $endpoint, array $params = []): ResponseInterface |
||
87 | |||
88 | /** |
||
89 | * @param string $endpoint |
||
90 | * @param array $params |
||
91 | * |
||
92 | * @throws GuzzleException |
||
93 | * @throws CouldNotSendNotification |
||
94 | * @return ResponseInterface |
||
95 | */ |
||
96 | public function post(string $endpoint, array $params = []): ResponseInterface |
||
100 | |||
101 | /** |
||
102 | * Send an API request and return response. |
||
103 | * |
||
104 | * @param string $endpoint |
||
105 | * @param array $options |
||
106 | * @param string $method |
||
107 | * |
||
108 | * @throws GuzzleException |
||
109 | * @throws CouldNotSendNotification |
||
110 | * @return mixed|ResponseInterface |
||
111 | */ |
||
112 | protected function api(string $endpoint, array $options, $method = 'GET') |
||
128 | } |
||
129 |