Пример #1
1
 /**
  * @param ParametersInterface|null $params
  * @return CountriesResponse
  */
 public function execute(ParametersInterface $params = null)
 {
     $client = new \GuzzleHttp\Client();
     $res = $client->request('GET', sprintf('http://peakclimber.com/api/countries/%s.json', $params->getParameter('id')));
     $resArr = json_decode($res->getBody(), true);
     return new CountriesResponse($resArr);
 }
Пример #2
0
 /**
  * @param $params ParametersInterface
  * @return array
  * @throws \SoapFault
  */
 public function execute(ParametersInterface $params = null)
 {
     $soapClient = new \SoapClient("http://www.biolib.cz/soap/findname.wsdl", array('trace' => 1));
     try {
         $result = $soapClient->findName($params->getParameter('name'), $params->getParameter('auth'));
     } catch (\SoapFault $fault) {
         throw $fault;
     }
     return new Response($result);
 }
Пример #3
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;
 }
Пример #4
0
 /**
  * @param ParametersInterface $params
  * @return bool
  */
 public function validateParameters(ParametersInterface $params)
 {
     return $params->isDefined('name');
 }