1 | <?php |
||
49 | class InstagramRequest |
||
50 | { |
||
51 | /** @var string $path */ |
||
52 | protected $path; |
||
53 | |||
54 | /** @var array $params */ |
||
55 | protected $params; |
||
56 | |||
57 | /** @var string $method */ |
||
58 | protected $method; |
||
59 | |||
60 | /** |
||
61 | * Remaining Rate Limit |
||
62 | * Sandbox = 500 |
||
63 | * Live = 5000 |
||
64 | * |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $xRateLimitRemaining = 500; |
||
68 | |||
69 | /** @var InstagramResponse $response */ |
||
70 | protected $response; |
||
71 | |||
72 | /** @var Instagram $instagram */ |
||
73 | protected $instagram; |
||
74 | |||
75 | /** |
||
76 | * Create the request and execute it to get the response |
||
77 | * |
||
78 | * @param Instagram $instagram |
||
79 | * @param string $path |
||
80 | * @param array $params |
||
81 | * @param string $method |
||
82 | */ |
||
83 | public function __construct(Instagram $instagram, $path, array $params = [], $method = 'GET') |
||
90 | |||
91 | /** |
||
92 | * Execute the Instagram Request |
||
93 | * |
||
94 | * @param void |
||
95 | * |
||
96 | * @throws InstagramResponseException |
||
97 | * |
||
98 | * @return InstagramResponse |
||
99 | */ |
||
100 | protected function execute() |
||
114 | |||
115 | /** |
||
116 | * Check Access Token is present. If not throw InstagramRequestException |
||
117 | * |
||
118 | * @throws InstagramRequestException |
||
119 | */ |
||
120 | protected function isAccessTokenPresent() |
||
126 | |||
127 | /** |
||
128 | * Get Response |
||
129 | * |
||
130 | * @return InstagramResponse |
||
131 | */ |
||
132 | public function getResponse() |
||
146 | |||
147 | /** |
||
148 | * Check whether api rate limit is reached or not |
||
149 | * |
||
150 | * @throws InstagramThrottleException |
||
151 | */ |
||
152 | private function isRateLimitReached() |
||
158 | |||
159 | /** |
||
160 | * Secure API Request by using endpoint, paramters and API secret |
||
161 | * |
||
162 | * @see https://www.instagram.com/developer/secure-api-requests/ |
||
163 | * |
||
164 | * @param InstagramApp $app |
||
165 | * @param string $endpoint |
||
166 | * @param array $params |
||
167 | * |
||
168 | * @return string (Signature) |
||
169 | */ |
||
170 | public static function generateSignature(InstagramApp $app, $endpoint, $params) |
||
180 | |||
181 | /** |
||
182 | * Get Api Rate Limit |
||
183 | * |
||
184 | * @return int |
||
185 | */ |
||
186 | public function getRateLimit() |
||
190 | } |
||
191 |