Facebook
From Commodious Leopard, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 80
  1. <?php
  2. $methodParams = '{
  3.     "storage_id": "bl_1",
  4.     "product_id": "",
  5.     "ean": "983628103943",
  6.     "sku": "EPL-432",
  7.     "name": "Harry Potter i kamie\u0144 filozoficzny",
  8.     "quantity": 12,
  9.     "price_brutto": 19.5,
  10.     "price_wholesale_netto": 12.44,
  11.     "tax_rate": 23,
  12.     "weight": 0.25,
  13.     "description": "Podstawowy opis ksi\u0105\u017cki",
  14.     "description_extra1": "Opis dodatkowy dotycz\u0105cy np. ca\u0142ej kategorii produkt\u00f3w",
  15.     "description_extra2": "Drugi opis dodatkowy - np. znaczniki IMG ze zdj\u0119ciami z zewnetrznego serwera",
  16.     "description_extra3": "Trzeci opis dodatkowy",
  17.     "description_extra4": "Czwarty opis dodatkowy",
  18.     "man_name": "Media Rodzina",
  19.     "category_id": "100583",
  20.     "images": [
  21.         "url:http:\/\/placehold.it\/250x250\/image.jpg",
  22.         "url:http:\/\/placehold.it\/250x250\/image2.jpg",
  23.         "url:http:\/\/placehold.it\/350x350\/image34.jpg"
  24.     ],
  25.     "features": [
  26.         {
  27.             "name": "Oprawa",
  28.             "value": "Twarda"
  29.         },
  30.         {
  31.             "name": "Ilo\u015b\u0107 stron",
  32.             "value": "300"
  33.         },
  34.         {
  35.             "name": "J\u0119zyk",
  36.             "value": "Polski"
  37.         }
  38.     ]
  39. }';
  40. $apiParams = [
  41.     "token" => "2000797-2001669-PYPJIKOS1IF2PA1K6149MI94WTQD3HBXAI4VLK2PSO1KA3RA7125CR1AIQVCYTHZ",
  42.     "method" => "addProduct",
  43.     "parameters" => $methodParams
  44. ];
  45.  
  46. $curl = curl_init("https://api.baselinker.com/connector.php");
  47. curl_setopt($curl, CURLOPT_POST, 1);
  48. curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiParams));  
  49. $response = curl_exec($curl);
  50.  
  51. $myJSON = json_decode($response, true); // dodalem to
  52.  
  53. $id = $myJSON['product_id']; // dodalem to
  54.  
  55. echo $myJSON; // to tesh
  56.  
  57.  
  58. ?>