Hi guys,
here is the code snippete to Integrate third-party API(Web Service) in WordPress, This is the post related to Integrate the SoftTouch API, using the SOAP client with cURL method. (using only the API Access Token method)
To initiate, connection and get products from SoftTouch API, following is the code snippete:
$authToken = 'your-api-access-token';
$base_url = 'your-api-base-url-with-account-id'; //eg. https://api.softtouch.eu/1/accounts/your-account-id-here/
base_url .= 'pass-your-api-requet-here'; //eg. if you want to get first 100 products then use, products?take=100
$httpRequest = curl_init();
curl_setopt($httpRequest, CURLOPT_HTTPHEADER, array('Authorization: ' . $authToken, 'Content-Type: application/json'));
curl_setopt($httpRequest, CURLOPT_URL, $base_url);
curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($httpRequest);
if ($response1 === FALSE){
die(curl_error($httpRequest));
}
curl_close($httpRequest);
$product_arr = json_decode($response);
thats it, in the $product_arr variable you will get first 100 products array response.
Note: Similarly, you can use different types of API requests according to your requirements.
Thank you,
