fadlyshafa

Untitled

Sep 27th, 2020
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $curl = curl_init();
  4.  
  5. curl_setopt_array($curl, array(
  6.   CURLOPT_URL => "https://api.rajaongkir.com/starter/cost",
  7.   CURLOPT_RETURNTRANSFER => true,
  8.   CURLOPT_ENCODING => "",
  9.   CURLOPT_MAXREDIRS => 10,
  10.   CURLOPT_TIMEOUT => 30,
  11.   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  12.   CURLOPT_CUSTOMREQUEST => "POST",
  13.   CURLOPT_POSTFIELDS => "origin=501&destination=114&weight=1700&courier=jne",
  14.   CURLOPT_HTTPHEADER => array(
  15.     "content-type: application/x-www-form-urlencoded",
  16.     "key: your-api-key"
  17.   ),
  18. ));
  19.  
  20. $response = curl_exec($curl);
  21. $err = curl_error($curl);
  22.  
  23. curl_close($curl);
  24.  
  25. if ($err) {
  26.   echo "cURL Error #:" . $err;
  27. } else {
  28.   echo $response;
  29. }
RAW Paste Data