Пример #1
0
 public function dispatch(ParametersInterface $params)
 {
     if (!$this->endpoint->validateParameters($params)) {
         throw new \Exception('Not valid parameters!');
     }
     $response = $this->adapter->request($this->endpoint, $params);
     if ($response instanceof \Exception) {
         throw $response;
     }
     return $response;
 }
Пример #2
0
 public function request(\Paro\Endpoints\EndpointInterface $endpoint, ParametersInterface $params)
 {
     $uri = $endpoint->getUri();
     /*foreach($params->getArray() as $key => $value) {
           $str = '{' . $key . '}';
           if (strpos($uri, $str)) {
               $uri = str_replace($str, $value, $uri);
           }
       }*/
     $endpointURI = $this->serverLocation;
     $endpointURI = str_replace('#ENDPOINTNAME#', $uri, $endpointURI);
     $endpointURI = str_replace('#PARAMS#', http_build_query($params->getArray()), $endpointURI);
     echo sprintf("request: %s<br>", $endpointURI);
     $response = file_get_contents($endpointURI);
     $responseDecoded = unserialize($response);
     return $responseDecoded;
 }