Import product in my woocommerce site from another site via API

Question

I want to import products from simpletire.com via the API they have given me. The API looks like this: Web Service Path : https://api.simpletire.com/wholesale/ENVIRONMENT/OPERATION/APIKEY

Parameters
1. ENVIRONMENT : This value can either be prod or sandbox. Both the environment will have different secret key
2. OPERATION: Operation to perform
3. APIKEY: Provided API KEY
Each operation requires a POST of JSON data

Example: API Response (JSON)

{
"status" : "success" ,
"current_page" : "1" ,
"total_items" : "201" ,
"brands" : [
{
"id" : "9" ,
"brand" : "BFGoodrich"
},
{
"id" : "11" ,
"brand" : "Bridgestone"
},
{
"id" : "15" ,
"brand" : "Continental"
},
{
"id" : "16" ,
"brand" : "Cooper"
},
{
"id" : "17" ,
"brand" : "Cordovan"
},
{
"id" : "25" ,
"brand" : "Doral"
},
{
"id" : "26" ,
"brand" : "Dunlop"
}
],
"items" : // array of items
[
{
"simple_item_id" : "123" , //SimpleTire item id (unique)
"in_stock" : "YES/NO" ,
"quantity" : "4" ,
"price" : "106.00" , //your buy price from SimpleTire
"item_number" : "987654321" , //manufacturer part number
"brand" : "Cooper" ,
"line" : "Trendsetter SE" ,
"size" : "205/60-16" ,
"loadindex" : 94 ,
"speedrating" : "H" ,
"utqg" : "560AA" ,
"warranty" : 60000 ,
"image" : "" , //https url to the main image
"description" : "" , //paragraph describing tire
"features" : [
"Feature 1" ,
"Feature 2" ,
"Feature 3"
]
}
], ….
}

Example: API Request (with CURL)

<?php
$curl = curl_init ();
curl_setopt_array( $curl , array (
CURLOPT_URL =>
"https://api.simpletire.com/wholesale/prod/inventory_check/0cfc3f81e47a6b6e06099cf890417d57" ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_ENCODING => "" ,
CURLOPT_MAXREDIRS => 10 ,
CURLOPT_TIMEOUT => 30 ,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
CURLOPT_CUSTOMREQUEST => "POST" ,
CURLOPT_POSTFIELDS => '{"merchant_id":"7","part_number":"421621","pn_type":"manf"}' ,
CURLOPT_HTTPHEADER => array (
"Cache-Control: no-cache" ,
"Content-Type: application/json" ,
"H-CHECKSUM: 4df21f42447693710351c911c088878c68b0dc828b014957c7d128c817db263c"
),
));
$response = curl_exec ( $curl );
$err = curl_error ( $curl );
curl_close ( $curl );
if ( $err ) {
echo "cURL Error #:" . $err ;
} else {
echo $response ;
}

I am blind stuck on how to proceed. Please help me to import the products in my site. Thanks in Advance.

0
INDRABHUSAN 7 months 0 Answers 83 views 0

Leave an answer