aus der Dokumentation habe ich folgenden Code entnommen:
Code: Alles auswählen
function generateHash()
{
$initKey = 'INITKEY AUS WAWISION';
$remoteDomain = '';
$date = gmdate('dmY');
$hash = "";
for($i = 0; $i <= 200; $i++)
$hash = sha1($hash . $initKey . $remoteDomain . $date);
return $hash;
}
Code: Alles auswählen
function SendRequest($methodname,$xml,$hash)
{
$url = 'URL VON WAWISION /WAWI/www/index.php?module=api&action='.$methodname.'&hash='.$hash;
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<request>
<status>
<function>'.$methodname.'</function>
</status>
<xml>'.$xml.'</xml>
</request>';
$data = array('xml' => $xml, 'md5sum' => md5($xml));
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
Code: Alles auswählen
public function index(){
$hash = $this->generateHash();
$xml = "<name>Muster Muster</name>
<strasse>Musterstrasse</strasse>
<hausnummer>21</hausnummer>
<plz>11111</plz>
<ort>Musterort</ort>
<email>emiliagruber@musterort.de</email>
<kundennummer>NEW</kundennummer>";
$output_xml = $this->SendRequest("AdresseCreate",$xml,$hash);
return view('admin.api.index');
}
Code: Alles auswählen
"""
<?xml version="1.0" encoding="UTF-8"?>\n
<response>\n
<status>\n
<action>AdresseCreate</action>\n
<message>Wrong Hash</message>\n
<messageCode>2</messageCode>\n
</status>\n
\n
</response>
"""