if ($webserviceType == "credential") { try { include "Envelope.php"; $client = new SoapClient("https://demo.docusign.net/API/3.0/Credential.asmx?WSDL"); $arr = array(); $response = $client->Ping($arr); if ($response->PingResult == "1") { echo "true"; } } catch (Exception $e) { echo $e; } } else { try { $ini_array = parse_ini_file("Credentials.ini"); $IntegratorsKey = $ini_array["IntegratorsKey"]; $username = $_SESSION["Email"]; $password = $_SESSION["Password"]; $client = new SoapClient("https://demo.docusign.net/API/3.0/Credential.asmx?WSDL"); $arr = array("Email" => $username, "Password" => $password); $response = $client->Login($arr); if ($response->LoginResult->AuthenticationMessage == "Successful authentication") { $f2 = true; } } catch (Exception $e) { echo $e; } if ($f2) { echo "true"; } }
function kasperskyBuy($params) { //$partnerID = 'KLTEST'; $deliveryDate = date('Y-m-d\T00:00:00\Z'); $client = new SoapClient('http://www.soha.ae/KLsales.asmx?WSDL'); // BEGIN LOGIN $strData = strlen(KASPERSKY_PARTNER_ID).KASPERSKY_PARTNER_ID.strlen($deliveryDate).$deliveryDate; $hash = $this->hmac($strData, KASPERSKY_SECURITY_KEY); $hash = strtoupper($hash); $loginParam = array( 'partId' => KASPERSKY_PARTNER_ID, 'date' => $deliveryDate, 'hash' => $hash ); $sessionID = $client->Login($loginParam)->LoginResult; // E N D LOGIN if ($sessionID != '1') { $param = array( 'SessionId' => $sessionID, 'Email' => $params['Email'], 'Time' => $deliveryDate, 'ProductUniqueCode' => $params['ProductUniqueCode'], 'Amount' => $params['Amount'], 'Discount' => $params['Discount'], 'Name' => $params['Name'], 'Tell' => $params['Tell'], 'Fax' => $params['Fax'], 'Country' => 'iran', 'City' => 'iran', 'Comment' => 'comment' ); $strResult = $client->Sale($param)->SaleResult; switch ($strResult) { case '1': throw new ServiceException('Invalid sessionId', 0); break; case '2': throw new ServiceException('Session timeout', 0); break; case '3': throw new ServiceException('Invalid ProductUniqCode: '.$param['ProductUniqueCode']); break; case '4': throw new ServiceException('BuyCeiling', 0); break; case '5': throw new ServiceException('End of validity period', 0); break; case '6': throw new ServiceException('Kaspersky Error', 0); break; case '7': throw new ServiceException('SOHA Error', 0); break; default: return $strResult; break; } } else { throw new ServiceException('Authentication failed', 0); } }
private function loginClient($email, $password) { $client = new SoapClient('http://www.lotto-api.de/WS_Version_1.1/WebService.php?WSDL'); try { $login = $client->Login($email, $password); if ($login) { return $client; } } catch (SoapFault $error) { return $error->faultstring; } }
<html> <head> <title>PHP SOAP Test</title> <style type="text/css"> body, html {font-family: Helvetica, Verdana, Arial; margin:10px; padding:0px; font-size:12px;} div.xml {height:200px;width:100%;overflow:auto;border:solid 1px #999;} </style> </head> <body> <?php $wsdl = "https://www.regonline.com/api/default.asmx?wsdl"; $client = new SoapClient($wsdl, array("trace" => 1, "exceptions" => 0, "cache_wsdl" => 0)); // Login $result = $client->Login(array("username" => "<USERNAME>", "password" => "<PASSWORD>")); // Get the API Token $apiToken = $result->LoginResult->Data->APIToken; // Setup the SOAP Header $authHeader = new AuthHeader(); $authHeader->APIToken = $apiToken; $header[] = new SoapHeader('http://www.regonline.com/api', 'TokenHeader', $authHeader, false); $client->__setSoapHeaders($header); // Makes the call to GetEvents $events = $client->GetEvents(array("filter" => 'Title.Contains("Testing")', "orderBy" => "")); // TODO: Do something with the results // Class for passing the APIToken class AuthHeader { var $APIToken; function __construct() {
} function __doRequest($request, $location, $action, $version) { $headers = array('Method: POST', 'Connection: Close', 'User-Agent: YOUR-USER-AGENT', 'Content-Type: text/xml', 'SOAPAction: "' . $action . '"', 'APIToken: "' . $this->apiToken . '"'); $ch = curl_init($location); curl_setopt_array($ch, array(CURLOPT_VERBOSE => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $request, CURLOPT_HEADER => false, CURLOPT_HTTPHEADER => $headers, CURLOPT_SSL_VERIFYPEER => false)); $response = curl_exec($ch); return $response; } } $wsdl = "https://www.regonline.com/api/default.asmx?wsdl"; $username = "******"; $password = "******"; $client = new SoapClient($wsdl, array("trace" => 1, "exceptions" => 0, "cache_wsdl" => 0)); // Login $result = $client->Login(array("username" => $username, "password" => $password)); // Get the API Token $apiToken = $result->LoginResult->Data->APIToken; $auth_client = new MSSoapClient($wsdl, array("trace" => 1, "exceptions" => 0, "cache_wsdl" => 0)); $auth_client->setToken($apiToken); // Makes the call to GetEvents $events = $auth_client->GetEvents(array("filter" => 'Title.Contains("Testing")', "orderBy" => "")); // TODO: Do something with the results ?> <h2>PHP SOAP Test (Using HTTP Headers)</h2> <p> This is a sample demonstration of calling the RegOnline API using the PHP SoapClient. It first calls the Login method to get the API Token and then passes the token to the GetEvents method via an HTTP Header. This is accomplished by extending the SoapClient class and using curl behind the scenes to make the request so HTTP headers can be appended. </p>