Example #1
0
 public function __construct(\apf\http\Adapter $adapter, array $config = array(), $parameters = array())
 {
     parent::__construct($adapter);
     if (sizeof($config)) {
         $this->setConfig($config);
     }
     if (sizeof($parameters)) {
         $this->setParameters($parameters);
     }
 }
Example #2
0
 public function __call($method, $args)
 {
     $context = strtolower($this->context);
     switch ($context) {
         case 'channel':
             $uri = 'http://' . 'x' . $this->contextId . 'x.' . $this->baseUri . '/' . $this->apiVersion . '/' . $method . '.' . $this->format;
             break;
     }
     if (sizeof($args)) {
         $uriArgs = array();
         foreach ($args as $arg) {
             if (!is_array($arg)) {
                 throw new \Exception("Arguments should be passed as array key=>value pairs");
             }
             foreach ($arg as $key => $value) {
                 $uriArgs[] = "{$key}={$value}";
             }
             $uri .= '?' . implode($uriArgs, '&');
         }
     }
     $this->setUri(new \apf\parser\Uri($uri));
     $this->adapter->setHttpMethod("GET");
     $response = parent::request();
     if (!$response) {
         throw new \Exception("Web service returned no response!");
     }
     $response = json_decode($response);
     $response = new Response($response->channel);
     return $response;
 }