Skip to content

Instantly share code, notes, and snippets.

@Traineratwot
Created October 5, 2022 08:36
Show Gist options
  • Save Traineratwot/217f36ab2961e916c54bc68cb8317440 to your computer and use it in GitHub Desktop.
Save Traineratwot/217f36ab2961e916c54bc68cb8317440 to your computer and use it in GitHub Desktop.
ini_set('display_errors', 1);
error_reporting(E_ERROR);
/**
* Created by Andrey Stepanenko.
* User: webnitros
* Date: 04.10.2022
* Time: 20:10
*/
$id = 170311;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://fandeco.ru/rest/products/' . $id,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Basic PEJhc2ljIEF1dGggVXNlcm5hbWU+OjxCYXNpYyBBdXRoIFBhc3N3b3JkPg==',
'Cookie: fandeco_redis=87ebf60b84bed6b4424cc46acbaef99e',
],
]);
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response, 1)['object'];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://fandeco.ru/rest/categories?limit=10000',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Basic PEJhc2ljIEF1dGggVXNlcm5hbWU+OjxCYXNpYyBBdXRoIFBhc3N3b3JkPg==',
'Cookie: fandeco_redis=87ebf60b84bed6b4424cc46acbaef99e',
],
]);
$response = curl_exec($curl);
curl_close($curl);
$cat = [
'cases',
];
$case = [];
$Desc = new Description();
$cat = NULL;
$categories = json_decode($response, 1);
foreach ($categories['results'] as $category) {
$cat = $category;
$Desc->setSingular($cat['pagetitle'], $cat['cases']['case_value_i']);
}
[$result, $raw, $disc] = $Desc->description($data);
echo '<pre>';
print_r($raw);
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment