public function testShouldCallMultipleByRedirect() { $this->curlProphecy = $this->prophesize('\\Curl\\Curl'); $this->curlProphecy->setOpt(Argument::type('integer'), Argument::any())->shouldBeCalled(); $this->curlProphecy->get(Argument::exact('http://some.dummy.url/foo'), Argument::type('array'))->will(function () { $this->http_status_code = 301; $this->response_headers = ['Location' => 'http://other.location/']; }); $this->curlProphecy->get('http://other.location/foo', [])->shouldBeCalled()->will(function () { $this->http_status_code = 200; $this->response_headers = null; }); $this->restClient = $this->getRestClient(); $this->restClient->send('foo', 'get'); }
protected function getAll($url, $method, array $parameters = [], array $postParameters = [], array $header = [], $content = '') { $skipping = 0; $newArr = []; $finish = false; while (!$finish) { $results = $this->restClient->send($url, $method, array_merge($parameters, ['$skip' => $skipping]), $postParameters, $header, $content); $skipping = 1000 + $skipping; if (empty($results)) { $finish = true; } else { $newArr = array_merge($newArr, $results); } } return $newArr; }
/** * getCanonicalized * * @param string $url * @param array $queryParams * @param string $method * @return string */ public function getAuthorizationString($url, $method, array $queryParams, array $header = []) { $result = $this->restClient->send('', 'post', [], [Constants::OAUTH_GRANT_TYPE => Constants::OAUTH_GT_CLIENT_CREDENTIALS, Constants::OAUTH_CLIENT_ID => $this->settings->getName(), Constants::OAUTH_CLIENT_SECRET => $this->settings->getKey(), Constants::OAUTH_SCOPE => Constants::MEDIA_SERVICES_OAUTH_SCOPE], ['Content-Type', 'application/x-www-form-urlencoded']); return 'Bearer ' . $result->access_token; }