Created
February 16, 2011 13:29
-
-
Save Krule/829363 to your computer and use it in GitHub Desktop.
Eogs class is a collection of methods used to communicate with cvr.dk SOAP service. Note: PHP must be compiled with SOAP, Curl, OpenSSL. On OS X (10.6.4+) OpenSSL lacks renegotiation support so it, and Curl afterward, must be recompiled from source before
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Eogs (V .4) class is a collection of methods used to communicate with cvr.dk SOAP | |
* service. | |
* | |
* Details on @link http://archprod.service.eogs.dk/cvronline/metacvronline/urls.htm | |
* | |
* @note .4 contains only adapters for two interfaces. | |
* | |
* @author Armin Pašalić <apasalic@devlogic.eu> | |
* @copyright Copyright (c) 2011, Devlogic d.o.o. | |
* @link http://www.devlogic.eu/ | |
* | |
* @license GPL_V3 | |
* @link http://www.gnu.org/licenses/gpl-3.0.html | |
* | |
* @todo Implement three more interfaces. | |
* | |
*/ | |
class Eogs | |
{ | |
private $user_id; | |
private $password; | |
/** | |
* @param integer $query Eight digit legal unit identifier | |
* @return StdClass eogs xml response converted to php object | |
*/ | |
public function get_legal_unit( $query = 0 ) | |
{ | |
$client = new SoapClient("http://archprod.service.eogs.dk/cvronline/metacvronline/LegalUnitGet_20080401.wsdl", | |
array('encoding' => "UTF-8", | |
'location' => "https://archprod.service.eogs.dk/cvronline/esb/LegalUnitGetSSLServicePort")); | |
try { | |
$response = $client->getLegalUnit( | |
array('level' => 1, | |
'UserId' => $this->user_id, | |
'Password' => $this->password, | |
'LegalUnitIdentifier' => $query) | |
); | |
} catch (Exception $e) { | |
$response = $e; | |
} | |
return $response; | |
} | |
/** | |
* @param string $query | |
* @return array eogs xml response converted to php object | |
*/ | |
public function search_legal_unit( $query = array() ) | |
{ | |
$client = new SoapClient("http://archprod.service.eogs.dk/cvronline/metacvronline/LegalUnitSearch_20080401.wsdl", | |
array('encoding' => "UTF-8", | |
'location' => "https://archprod.service.eogs.dk/cvronline/esb/LegalUnitSearchSSLServicePort")); | |
try { | |
$list = $client->SearchLegalUnit( | |
array('maximumNumberOfResultsType' => 5, | |
'UserId' => $this->user_id, | |
'Password' => $this->password, | |
'SearchName' => "*" . $query . "*") | |
); | |
$response = array(); | |
if (isset($list->LegalUnitIdentifierCollection->LegalUnitIdentifier)) { | |
if (!is_array($list->LegalUnitIdentifierCollection->LegalUnitIdentifier)) { | |
$list->LegalUnitIdentifierCollection->LegalUnitIdentifier = array($list->LegalUnitIdentifierCollection->LegalUnitIdentifier); | |
} | |
foreach ($list->LegalUnitIdentifierCollection->LegalUnitIdentifier as $value) { | |
array_push($response, $this->get_legal_unit($value)); | |
} | |
} | |
} catch (Exception $e) { | |
$response = array($e); | |
} | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment