Advertisement
Sebuahhobi98

cURL

Aug 31st, 2021
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. function cURL($temp, $url){
  2.     // header('Content-Type: application/json');
  3.     $curl = curl_init();
  4.     curl_setopt_array($curl, array(
  5.         CURLOPT_URL => 'https://api-dev.fastravel.co.id/' . $url,
  6.         CURLOPT_RETURNTRANSFER => true,
  7.         CURLOPT_ENCODING => '',
  8.         CURLOPT_MAXREDIRS => 10,
  9.         CURLOPT_TIMEOUT => 0,
  10.         CURLOPT_FOLLOWLOCATION => true,
  11.         CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  12.         CURLOPT_CUSTOMREQUEST => 'POST',
  13.         CURLOPT_POSTFIELDS => json_encode($temp),
  14.         CURLOPT_HTTPHEADER => array(
  15.             'Content-Type: application/json'
  16.         ),
  17.     ));
  18.  
  19.     $response = curl_exec($curl);
  20.  
  21.     curl_close($curl);
  22.  
  23.     return $response;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement