Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. $authorization = 'Basic '.base64_encode($this->client_id.':'.$this->client_secret);
  2.         $guzzle = new Client();
  3.         try {
  4.             $guzzle->post(
  5.                 $this->oauth_url,
  6.                 [
  7.                     'headers' => [
  8.                         'Content-Type' => 'application/x-www-form-urlencoded',
  9.                         'Authorization' => $authorization,
  10.                     ],
  11.                     'form_params' => [
  12.                         'grant_type' => 'authorization_code',
  13.                         'code' => $code,
  14.                         'redirect_uri' => $this->ruName,
  15.                     ],
  16.                 ]
  17.             )->getBody()->getContents();
  18.         } catch (BadResponseException $e) {
  19.             $response = $e->getResponse()->getBody();
  20.             $response->rewind();
  21.             dd(json_decode((string)$response->getContents()));
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement