Esempio n. 1
0
 /**
  * Send request to IMASYS Messaging Platform
  *
  * @param RequestInterface $request
  * @throws \Exception
  */
 public function send(RequestInterface $request)
 {
     $url = $request->buildUrl($this->credentials, $this->portalServers->getPortalServer(), 443);
     $body = $request->buildBody();
     $curlRequest = new CurlRequest($url);
     $curlRequest->setPostBody(urlencode($body));
     $curlRequest->run();
     if (!$curlRequest->wasSuccessful()) {
         throw new \Exception();
     }
     $curlResponse = $curlRequest->response;
     return $request->parseResponse($curlResponse);
 }
Esempio n. 2
0
 /**
  * Fetches the portal urls.
  *
  * @param string $host
  * @param Credentials $credentials
  * @return PortalServers
  */
 private function fetchPortalServers()
 {
     $urls = [];
     $url = $this->host . '/IZ/GetPortalList.aspx?';
     $data = ['UserID' => $this->credentials->getUserName(), 'Pwd' => $this->credentials->getPassword()];
     $url = $url . http_build_query($data);
     $request = new Request($url);
     $request->run();
     if (!$request->wasSuccessful()) {
         throw new \Exception($request->response->getState()['httpCode'] . ' on fetching Portal Servers with url: ' . $url);
     }
     $xml = simplexml_load_string($request->response->getState()['body']);
     foreach ($xml->ISPortals->children() as $portal) {
         array_push($urls, (string) $portal->Url);
     }
     return $urls;
 }