1 | <?php |
||
12 | class InstagramRequest |
||
13 | { |
||
14 | /** @var string $path */ |
||
15 | private $path; |
||
16 | |||
17 | /** @var array $params */ |
||
18 | private $params; |
||
19 | |||
20 | /** @var string $method */ |
||
21 | private $method; |
||
22 | |||
23 | /* |
||
24 | * Remaining Rate Limit |
||
25 | * Sandbox = 500 |
||
26 | * Live = 5000 |
||
27 | * @var array $x_rate_limit_remaining |
||
28 | */ |
||
29 | private $xRateLimitRemaining = 500; |
||
30 | |||
31 | /** @var InstagramResponse $response */ |
||
32 | protected $response; |
||
33 | |||
34 | /** @var Instagram $instagram */ |
||
35 | protected $instagram; |
||
36 | |||
37 | /* |
||
38 | * Create the request and execute it to get the response |
||
39 | * @param Instagram $instagram |
||
40 | * @param string $path |
||
41 | * @param array $params |
||
42 | * @param string $method |
||
43 | */ |
||
44 | public function __construct(Instagram $instagram, $path, array $params = array(), $method = 'GET') |
||
51 | |||
52 | /* |
||
53 | * Execute the Instagram Request |
||
54 | * @param void |
||
55 | * @return InstagramResponse |
||
56 | */ |
||
57 | protected function execute() |
||
77 | |||
78 | /* |
||
79 | * Check Access Token is present. If not throw InstagramRequestException |
||
80 | * @throws InstagramRequestException |
||
81 | */ |
||
82 | protected function isAccessTokenPresent() |
||
88 | |||
89 | /* |
||
90 | * Get Response |
||
91 | * @return InstagramResponse |
||
92 | */ |
||
93 | public function getResponse() |
||
98 | |||
99 | /* |
||
100 | * Check whether api rate limit is reached or not |
||
101 | * @throws InstagramThrottleException |
||
102 | */ |
||
103 | private function isRateLimitReached() |
||
109 | |||
110 | /* |
||
111 | * Secure API Request by using endpoint, paramters and API secret |
||
112 | * copy from Instagram API Documentation: https://www.instagram.com/developer/secure-api-requests/ |
||
113 | * |
||
114 | * @param string $secret |
||
115 | * @param string $endpoint |
||
116 | * @param array $params |
||
117 | * |
||
118 | * @return string (Signature) |
||
119 | */ |
||
120 | public static function generateSignature($secret, $endpoint, $params) |
||
129 | |||
130 | /* |
||
131 | * @return int |
||
132 | */ |
||
133 | public function getRateLimit() |
||
137 | } |
||
138 |