core/parcer/s1cat.php

57 lines
1.5 KiB
PHP

<?php
$_SERVER['SERVER_NAME']='tk-ligat.ru';
require_once('/home/cloud/core/set/tk-ligat.ru.php');
require_once('/home/cloud/core/api/php/db.php');
require_once('/home/cloud/core/api/php/json.php');
/*$curl = curl_init('https://api.samsonopt.ru/v1/sku/?api_key=4e2ef85d3ec9e27cc2a148c74a47d804');
$arHeaderList = array();
$arHeaderList[] = 'Accept: application/json';
$arHeaderList[] = 'User-Agent: string';
$arHeaderList[] = 'Accept-Encoding: gzip';
curl_setopt($curl, CURLOPT_HTTPHEADER, $arHeaderList);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
$result = curl_exec($curl);
curl_close($curl);*/
$code=100264;
$curl = curl_init('https://api.samsonopt.ru/v1/sku/' . $code . '/?api_key=4e2ef85d3ec9e27cc2a148c74a47d804');
$arHeaderList = array();
$arHeaderList[] = 'Accept: application/json';
$arHeaderList[] = 'User-Agent: string';
$arHeaderList[] = 'Accept-Encoding: gzip';
curl_setopt($curl, CURLOPT_HTTPHEADER, $arHeaderList);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
$result = curl_exec($curl);
curl_close($curl);
$tovar=json::from_j($result);
$cat_id=$tovar['data'][0]['category_list'][0];
while ($parrent!=0){
$cat_name=DB::getAll("SELECT * FROM `samson` WHERE `id`=? LIMIT 1", $cat_id);
print_r($cat_name);
$cat_id=$cat_name[0]['parent'];
$parrent=$cat_name[0]['parent'];
}
?>