예제 #1
0
 /**
  * Function to retrieve a bearer token from a remote URL
  *
  * @return  void
  *
  * @since   3.1
  * @throws  RuntimeException
  */
 protected function callRemoteUrl()
 {
     $url = $this->params->get('remote_url', 'http://tdbtoken-v2.gopagoda.io/tokenRequest.php');
     // Call consumer or RemoteURL
     $response = $this->connector->get($url);
     if ($response->code == 200) {
         $this->token = str_replace('Bearer ', '', base64_decode($response->body));
     } else {
         throw new RuntimeException('Could not retrieve bearer token (remote)');
     }
     $this->writeCache();
 }
예제 #2
0
 /**
  * Function to fetch a JSON feed
  *
  * @param   string  $req  The URL of the feed to load
  *
  * @return  object  The fetched JSON query
  *
  * @since   1.0
  * @throws  RuntimeException
  */
 public function getJSON($req)
 {
     // Get the data
     try {
         $headers = array('Authorization' => "Bearer {$this->bearer->token}");
         $response = $this->connector->get($req, $headers);
     } catch (Exception $e) {
         return null;
     }
     // Return the decoded response body
     return json_decode($response->body);
 }