Guest User

Untitled

a guest
Jan 19th, 2020
168
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       $credentials = $this->get_credentials();
  2.         $credentials = base64_encode($credentials['login'].':'.$credentials['password']);
  3.  
  4.         $ch = curl_init();
  5.  
  6.         $params = array(
  7.             "name" => "badmintonist_test_".$order['id'],
  8.             "description" => "Тестовый заказ с badmintonist - не обрабатывать",
  9.             "employee" => array(
  10.                 "meta" => $owner[0]["meta"],
  11.             ),
  12.             "organization" => array(
  13.                 "meta" => $organization[0]["meta"]
  14.             ),
  15.             "agent" => array(
  16.                 "meta" => $agent["meta"]
  17.             )
  18.         );
  19.  
  20.         curl_setopt($ch, CURLOPT_URL, 'https://online.moysklad.ru/api/remap/1.1/entity/customerorder');
  21.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22.         curl_setopt($ch, CURLOPT_POST, 1);
  23.         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK));
  24.  
  25.         $headers = array();
  26.         $headers[] = 'Authorization: Basic '.$credentials;
  27.         $headers[] = 'Content-Type: application/json';
  28.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  29.  
  30.         $result = json_decode(curl_exec($ch), true);
  31.         if (curl_errno($ch)) {
  32.             echo 'Error:' . curl_error($ch);
  33.         }
  34.         curl_close($ch);
RAW Paste Data