-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetRestrictedProducts.php
50 lines (31 loc) · 1.31 KB
/
getRestrictedProducts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once 'inc/config.php';
$csv = "ARTNR;MOIN;ErrorCode" . PHP_EOL;
$page = 0;
do{
$restricted = getRestrictedProducts($url, $accessToken, $page);
foreach($restricted["marketPlaceStatus"] as &$value){
$csv .= $value["sku"] . ";" . $value["moin"] . ";" . $value["errors"][0]["code"] . PHP_EOL;
}
logMe("Restricted page:" . $page);
$page++;
} while (sizeof($restricted["marketPlaceStatus"]) === 100);
$file = 'inc/restricted.csv';
//Write csv to file
file_put_contents($file, $csv);
function getRestrictedProducts($url, $accessToken, $page){
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '/v2/products/marketplace-status?marketPlaceStatus=RESTRICTED&page=' . $page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Authorization: Bearer ' . $accessToken;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
return json_decode($result, true);
}