Static Public Member Functions | |
| static | authenticationTest ($auth) |
| static | createShortURL ($auth, $url, $params=array()) |
| static | getCellularCarrierId ($auth, $phone_list) |
| static | test () |
| static authenticationTest | ( | $ | auth | ) | [static] |
Description:
| WSSimpleAuthentication | $auth | Simple Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company |
result - True/False, This will indicate whether the request was successful or not. error_code - If there was an error in the request it will return an error number here. message - Message stating if authentication was successful or not
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array(); $auth['username'] = 'api_username'; $auth['password'] = 'api_password'; $auth['api_key'] = 'xxxxxxxxxxxxxx'; $results = $soap->authenticationTest($auth); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:webservices2_0_0">
<soapenv:Header/>
<soapenv:Body>
<urn:authenticationTest soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<auth xsi:type="urn:WSAuthentication">
<username xsi:type="xsd:string">api_username</username>
<password xsi:type="xsd:string">api_password</password>
<api_key xsi:type="xsd:string">xxxxxxxxxxxxxx</api_key>
</auth>
</urn:authenticationTest>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:webservices2_0_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:authenticationTestResponse>
<authenticationTestReturn xsi:type="ns1:WSGenericResponse">
<message xsi:type="xsd:string">User [username] authenticated successfully.</message>
<response xsi:nil="true"/>
<result xsi:type="xsd:boolean">true</result>
</authenticationTestReturn>
</ns1:authenticationTestResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
//create web service authentication WSAuthentication auth = new WSAuthentication(); auth.username = "api_username"; auth.password = "api_password"; auth.api_key = "xxxxxxxxxxxxxx"; //create task bind WS_TaskBinding bind = new WS_TaskBinding(); bind.Url = "SSL//HOST_URL/webservices/task/2.0.0"; //create result object WSGenericResponse ws_result = new WSGenericResponse(); //call bind event ws_result = bind.authenticationTest(auth); //check to see if there was an error if (!ws_result.result) { //handle error label.Text = ws_result.message; } else { //handle successful response label.Text = ws_result.message; }
| static createShortURL | ( | $ | auth, |
| $ | url, | ||
| $ | params = array() |
||
| ) | [static] |
| WSAuthentication | $auth | |
| string | $url | |
| WSCustomField[] | $params |
| static getCellularCarrierId | ( | $ | auth, |
| $ | phone_list | ||
| ) | [static] |
Description:
| WSSimpleAuthentication | $auth | Simple Authentication Object username - String[40] (Required) - Username for company credentials password - String[40] (Required) - Password for company credentials api_key - String[40] (Required) - Credentials for company |
| string | $phone_list | Phone List phone_list - String (Required) - Comma seperated list of phone numbers to be checked (with country code) |
result - True/False, This will indicate whether the request was successful or not. error_code - If there was an error in the request it will return an error number here. carrier - Carrier of the cellular phone number carrier_id - Carrier ID of the cellular phone number international - True = It is an international number, False = It is not international landline - True = It is a landline number, False = It is not a landline phone - The phone number that was checked
Code Examples:
<?php $wsdl = 'SSL//HOST_URL/webservices/?version=2.0.0&wsdl'; $soap = new SoapClient($wsdl); //create an authentication object $auth = array(); $auth['username'] = 'api_username'; $auth['password'] = 'api_password'; $auth['api_key'] = 'xxxxxxxxxxxxxx'; //set phone number (could be a comma seperated list, max of 100) $phone = '18885554433'; $results = $soap->getCellularCarrierId($auth, $phone); print_r($results); if ($results->result == 0 || $results->error > 0) { //error processing throw new Exception($results->message); } else { //after success processing }
SOAP Request <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservices2_0_0"> <soapenv:Header/> <soapenv:Body> <urn:getCellularCarrierId soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <auth xsi:type="urn:WSSimpleAuthentication"> <!--You may enter the following 3 items in any order--> <api_key xsi:type="xsd:string">${api_key}</api_key> <password xsi:type="xsd:string">${password}</password> <username xsi:type="xsd:string">${username}</username> </auth> <phone xsi:type="xsd:string">18885554433</phone> </urn:getCellularCarrierId> </soapenv:Body> </soapenv:Envelope> SOAP Response <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:webservices2_0_0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:getCellularCarrierIdResponse> <getCellularCarrierIdReturn xsi:type="ns1:WSCarrierPhoneResponse"> <error_code xsi:type="xsd:int">0</error_code> <message xsi:type="xsd:string">Successfully found carrier.</message> <response xsi:type="ns1:WSCarrierPhoneList"> <list SOAP-ENC:arrayType="ns1:WSCarrierPhoneRow[1]" xsi:type="ns1:WSCarrierPhoneRowArray"> <item xsi:type="ns1:WSCarrierPhoneRow"> <carrier xsi:type="xsd:string">Wireless Carrier</carrier> <carrier_id xsi:type="xsd:string">Wireless Carrier ID</carrier_id> <international xsi:type="xsd:boolean">false</international> <invalid xsi:type="xsd:boolean">false</invalid> <landline xsi:type="xsd:boolean">false</landline> <phone xsi:type="xsd:string">18885554433</phone> </item> </list> </response> <result xsi:type="xsd:boolean">true</result> </getCellularCarrierIdReturn> </ns1:getCellularCarrierIdResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
//Get Cellular CarrierId Example WS_TaskBinding bind = new WS_TaskBinding(); bind.Url = "SSL//HOST_URL/webservices/task/2.0.0"; WSSimpleAuthentication auth = new WSSimpleAuthentication(); auth.api_key = "xxxxxxxxxxxxxx"; auth.username = "api_username"; auth.password = "api_password"; string phone = "18885554433"; WSCarrierPhoneResponse response = bind.getCellularCarrierId(auth, phone); if (response.result == true) { //loop through the list and process the response for each number. WSCarrierPhoneList list = response.response; } else { //do error handling }
Request SSL//HOST_URL/httppost/nvp?version=2.0.0&method_name=task.getCellularCarrierId&username={username}&password={password}&api_key={api_key}&phone=18885554433,18885554422 Response <?xml version="1.0" encoding="utf-8"?> <getCellularCarrierId> <message>Successfully found carrier.</message> <error_code></error_code> <result>true</result> <response> <list> <item> <carrier>cingular</carrier> <phone>18885554433</phone> <landline>false</landline> <invalid>false</invalid> <international>false</international> </item> <item> <carrier>Verizon Wireless</carrier> <phone>18885554422</phone> <landline>false</landline> <invalid>false</invalid> <international>false</international> </item> </list> </response> </getCellularCarrierId>
| static test | ( | ) | [static] |
A simple test to verify the web services are working.