/**
  * Sends an HTTP request to the supplied url and returns the response as
  * an JSON-decoded php datastructure (usually an array; may be a string).
  *   eg. '/services/v3/activities?newer_than_version=134'
  * 
  * @param string $url
  * @return array
  */
 protected function sendRequest($url)
 {
     $request = new \Altumo\Http\OutgoingHttpRequest('https://www.pivotaltracker.com' . $url);
     $request->addHeader('X-TrackerToken', $this->getToken());
     $response = $request->send();
     return json_decode(\Altumo\Javascript\Json\JsonFormatter::convertXmlToJson($response));
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     $url = $options['url'];
     $api_key = $options['api-key'];
     $request = new \Altumo\Http\OutgoingHttpRequest($url);
     $request->setVerifySslPeer(false);
     $request->addHeader('Authorization', sprintf('Basic %s', base64_encode(sprintf('%s:X', $api_key))));
     echo $request->send();
 }
Exemple #3
0
 /**
  * Getter for the session field on this ApiClient.
  *
  * @return \Altumo\Http\OutgoingHttpRequest
  */
 public function getSession()
 {
     //there is an outstanding bug in the curl library that prevents
     //persistent sessions from working properly
     //so we create a temporarily create a new OutgoingHttpRequest
     //for every request (hence the 1 below)
     if (1 || !$this->session instanceof \Altumo\Http\OutgoingHttpRequest) {
         if ($this->getHttps()) {
             $scheme = 'https';
         } else {
             $scheme = 'http';
         }
         $request = new \Altumo\Http\OutgoingHttpRequest($scheme . '://' . $this->getHostname());
         $request->addHeader('Accept', 'application/json');
         $request->setVerifySslPeer($this->getVerifySslPeer());
         $this->session = $request;
     }
     return $this->session;
 }