Auth0\SDK\API\Helpers\RequestBuilder::call PHP Method

call() public method

public call ( )
    public function call()
    {
        $client = new Client($this->getGuzzleOptions());
        try {
            $data = ['headers' => $this->headers, 'body' => $this->body];
            if (!empty($this->files)) {
                $data['multipart'] = $this->buildMultiPart();
            } else {
                if (!empty($this->form_params)) {
                    $data['form_params'] = $this->form_params;
                }
            }
            $response = $client->request($this->method, $this->getUrl(), $data);
            $body = (string) $response->getBody();
            if (strpos($response->getHeaderLine('content-type'), 'json') !== false) {
                return json_decode($body, true);
            }
            return $body;
        } catch (RequestException $e) {
            throw $e;
        }
    }

Usage Example

Example #1
0
 public function fetchKeys($iss)
 {
     $url = "{$iss}.well-known/jwks.json";
     if (($secret = $this->cache->get($url)) === null) {
         $secret = [];
         $request = new RequestBuilder(array('domain' => $iss, 'basePath' => '.well-known/jwks.json', 'method' => 'GET', 'guzzleOptions' => $this->guzzleOptions));
         $jwks = $request->call();
         foreach ($jwks['keys'] as $key) {
             $secret[$key['kid']] = $this->convertCertToPem($key['x5c'][0]);
         }
         $this->cache->set($url, $secret);
     }
     return $secret;
 }