Servus liebe Community,
Ich bin grade dabei eine einfache Klasse zu der API zu schreiben und wollte jetzt mit einer Funktion Kontakt, Kunde, Benutzer und Hosting anlegen und habe es theoretisch auch alles richtig doch ich bekomme die Antwort:
Error while calling Web Service: Invalid token
Dies ist die Funktion:
PHP
public function UserAdd($salutation, $firstname, $lastname, $address1, $zipcode, $city, $country, $email, $domain) {
// ContactAdd
$aufruf = $this->authcode('ContactAdd');
$auth = $this->auth;
$aufruf = $this->wsdlurl();
$client = $this->client;
$params = array('auth' => $auth,
'salutation' => $salutation,
'firstname' => $firstname,
'lastname' => $lastname,
'address1' => $address1,
'zipcode' => $zipcode,
'city' => $city,
'country' => $country,
'email' => $email
);
try {
$response = $client->ContactAdd($params);
} catch (SoapFault $soapFault) {
die("Error while calling Web Service: " . $soapFault->faultstring . "\n");
}
$ContactID = $response->id;
// CustomerAdd
$aufruf = $this->authcode('CustomerAdd');
$auth = $this->auth;
$aufruf = $this->wsdlurl();
$client = $this->client;
$params = array('auth' => $auth,
'owner_c' => $ContactID,
'admin_c' => $ContactID,
'billing_c' => $ContactID,
'locked' => 0,
);
try {
$response = $client->CustomerAdd($params);
} catch (SoapFault $soapFault) {
die("Error while calling Web Service: " . $soapFault->faultstring . "\n");
}
$CustomerID = $response->cid;
//UserAdd
$aufruf = $this->authcode('UserAdd');
$auth = $this->auth;
$aufruf = $this->wsdlurl();
$client = $this->client;
srand((double)microtime()*1000000);
$Buchstaben = array("a", "b", "c", "d", "e", "f", "g", "h", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
$Zahlen = array("2", "3", "4", "5", "6", "7", "8", "9");
$Sonderzeichen = array(".", "!", "%", "&", "=", "?");
$Laenge = 10;
for($i = 0, $password = ""; strlen($password) < $Laenge; $i++)
{
if(rand(0, 2) == 0 && isset($Buchstaben))
{
$password .= $Buchstaben[rand(0, count($Buchstaben))];
}
elseif(rand(0, 2) == 1 && isset($Zahlen))
{
$password .= $Zahlen[rand(0, count($Zahlen))];
}
elseif(rand(0, 2) == 2 && isset($Sonderzeichen))
{
$password .= $Sonderzeichen[rand(0, count($Sonderzeichen))];
}
}
$params = array('auth' => $auth,
'customer' => $CustomerID,
'contact' => $ContactID,
'login' => $email,
'password' => $password,
);
try {
$response = $client->UserAdd($params);
} catch (SoapFault $soapFault) {
die("Error while calling Web Service: " . $soapFault->faultstring . "\n");
}
$UserID = $response->id;
// HostingSubscriptionAdd
$aufruf = $this->authcode('HostingSubscriptionAdd');
$auth = $this->auth;
$aufruf = $this->wsdlurl();
$client = $this->client;
$params = array('auth' => $auth,
'subscriptionname' => $domain,
'plan' => 'Starter'
);
try {
$response = $client->HostingSubscriptionAdd($params);
} catch (SoapFault $soapFault) {
die("Error while calling Web Service: " . $soapFault->faultstring . "\n");
}
$HostingID = $response->id;
$subscriptionname = $response->subscriptionname;
// HostingDomainAdd
$aufruf = $this->authcode('HostingDomainAdd');
$auth = $this->auth;
$aufruf = $this->wsdlurl();
$client = $this->client;
$params = array('auth' => $auth,
'subscriptionname' => $subscriptionname,
'domain' => $domain,
'mail' => 1
);
try {
$response = $client->HostingDomainAdd($params);
} catch (SoapFault $soapFault) {
die("Error while calling Web Service: " . $soapFault->faultstring . "\n");
}
$DomainID = $response->id;
echo $ContactID.$CustomerID.$UserID.$HostingID.$DomainID;
}
Alles anzeigen
- Das echo am ende soll erstmal nur dazu dienen um zu schauen ob auch alle erstellt wurden.
- Die Funktion 'authcode' generiert den passenden Code für die jewahlige abfrage
- & die 'wsdlurl'-Funktion generiert diese...
Würde mich freuen wenn jemand den Fehler finden würde...