Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2. $sellerId = 3;
  3.  
  4. include("../../amzing.class.php");
  5.  
  6. function apiDebug($html) {
  7. $hh = fopen("CAZZO.txt", "a");
  8. fwrite($hh, $html . "\n\n\n--------------------------------------\n\n\n");
  9. fclose($hh);
  10. print $html;
  11. }
  12.  
  13. $Amzing = new Amzing;
  14. $ch = curl_init();
  15. curl_setopt($ch, CURLOPT_URL, "https://www.amz-review.com/api/?username=sganga.i1&password=123456&action=getproducts&nation=IT1&format=jsongetproducts");
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  17. curl_setopt($ch, CURLOPT_HEADER, false);
  18. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  19. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  20.  
  21. $Products = json_decode(curl_exec($ch), true);
  22. curl_close($ch);
  23.  
  24. if(!$Products)
  25. die("not json");
  26.  
  27.  
  28. $currentProducts = $Amzing->getProductsBySellerId($sellerId);
  29. print_r($Products);
  30. $toRemove = Array();
  31. foreach($currentProducts as $Asin => $currentProduct) {
  32. if(!isset($Products[$Asin]))
  33. $toRemove[] = $Asin;
  34. }
  35.  
  36. foreach($toRemove as $ASIN) {
  37. if(!$Amzing->disableProduct($Asin, $sellerId))
  38. apiDebug("BORDELLO! PRODOTTO {$ASIN} NON SI E' DISABILITATO E NON CI SONO QUANTITA'!");
  39. }
  40.  
  41. foreach($Products as $Asin => $Product) {
  42. if($Product['fees'] == "YES" and $Product['pieces'] > 1) {
  43. if(isset($currentProducts[$Asin]))
  44. $Amzing->updateProductQty($Asin, $sellerId, $Product['pieces'], $Product['pieces'], $Product['pieces']);
  45. else {
  46. if(!$Amzing->getProductFromASIN($Asin, "IT"))
  47. $Amzing->insertProduct("IT", $Product['product'], $Asin, "", $Product['pieces'], $Product['pieces'], $Product['pieces'], 100, htmlentities($Product['note']), "", 18, $sellerId, 1, "francescosg0e-21", 0);
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement