public function compose(View $view)
 {
     $view->with('access_token', Api::getAccessToken());
 }
Example #2
0
 /**
  * User the guzzle client to perform a request to the API service.
  *
  * @param string $method one of 'get', 'post', 'put', or 'delete'
  * @param string $url the URL of the resource to request
  * @param array $payload the request body and/or query parameters
  *
  * @return array the raw JSON response
  */
 public static function request($method, $url, $payload)
 {
     # ensure the access token is present in the headers.
     $token = Api::getAccessToken();
     $payload['headers'] = ['Authorization' => 'Bearer ' . $token];
     $payload['future'] = true;
     # create the request
     $request = self::client()->createRequest($method, $url, $payload);
     $response = self::client()->send($request);
     return new Response($response);
 }