protected function call($function, array $params) { if (empty($this->shopId) || empty($this->login) || empty($this->pwd)) { throw new \Exception('Missing auth params'); } $authParams = array('pid_loja' => $this->shopId, 'plogin' => $this->login, 'psenha' => $this->pwd); return $this->soapClient->__soapCall($function, $authParams + $params); }
/** * Handles soap call and return weather array * @param string $country * @param string $city * @return array */ public function soapClientCall($country, $city) { $url = $this->url; $client = new SoapClient($url); if (!$city) { $city = ''; } if (!$country) { $country = ''; } $serviceParams = array(self::SOAPAPIPARAM => array("CityName" => $city, "CountryName" => $country)); $result = $client->__soapCall(self::SOAPAPIPARAM, $serviceParams); $weatherResult = $result->GetWeatherResult; //converting xml to json and then to array if ($weatherResult != 'Data Not Found') { $responseXml = simplexml_load_string(preg_replace('/(<\\?xml[^?]+?)utf-16/i', '$1utf-8', $weatherResult)); $responseJson = json_encode($responseXml); $responseArray = json_decode($responseJson, TRUE); } else { $responseArray = 'Data not found'; } return $responseArray; }
/** * {@inheritDoc} */ public function doCall($method, array $parameters = []) { // open connection if needed if (($this->soapClient === null || $this->token === null) && $this->login !== null) { $this->openApiConnection(); } // parameters strings should be UTF8 foreach ($parameters as $key => $value) { if ('string' === gettype($value) && 'UTF-8' !== mb_detect_encoding($value)) { $parameters[$key] = utf8_encode($value); } } $parameters['token'] = $this->token; try { $response = $this->soapClient->__soapCall($method, [$parameters]); if (!isset($response->return)) { return null; } return $response->return; } catch (\SoapFault $fault) { throw new APIException('CampaignCommander API operation error', 0, $fault); } }