In this blog post we explain you that how you can authenticates the token generated by the Generate Token method for customer using httpapi.com api and returns the Customer details, if token authenticated. It requires GET HTTP Method. You need auth-userid, api-key or auth-password, and token parameters for process. If the token is authenticated then you will be get the below customer details in response:
Customer Id (customerid)
Customer Username (username)
Reseller Id of the Parent Reseller (resellerid)
Name (name)
Company (company)
Email Address (useremail)
Telephone Number Country Code (telnocc)
Telephone Number (telno)
First line of address of the Customer (address1)
Second line of address of the Customer (address2)
Third line of address of the Customer (address3)
City (city)
State (state)
Country Code (country)
ZIP Code (zip)
Personal Identification Number (pin)
Creation Date (creationdt)
Current Status (customerstatus)
Sales Contact Id (salescontactid)
Language Preference for the Control Panel and Emails (langpref)
Total Receipts (totalreceipts)
In case of any errors, a status key with value as ERROR alongwith an error message will be returned. For Authenticating a Token you can use following function.
<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function AUTHENTICATE_TOKEN($token) { # API Url: for test=>https://test.httpapi.com , for live=>https://httpapi.com $api_url = 'https://test.httpapi.com'; $auth_userid = ''; // reseller unique id $api_key = ''; // api-key or reseller password if(isset($token)) { $check_token = $api_url.'/api/customers/authenticate-token.json?auth-userid='.$auth_userid.'&api-key='.$api_key.'&token='.$token; $result = @file_get_contents($check_token); $response = json_decode($result, true); return $response; } return false; } ?>
Function USAGE
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/
$_customer = AUTHENTICATE_TOKEN("token");
if($_customer)
{
// Customer details if the token is authenticated
print_r($_customer);
}
else
{
echo "Invalid token.";
}
?>
0 comments:
Post a Comment