Advertisement
Guest User

json data

a guest
Mar 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. $ch = curl_init();
  4.  
  5. $url = "http://localhost/curl/jsonData/data.json";
  6.  
  7. curl_setopt_array($ch, array(
  8.  
  9. CURLOPT_URL => $url,
  10. CURLOPT_RETURNTRANSFER => true,
  11. CURLOPT_HTTPGET => true,
  12. CURLOPT_HTTPHEADER, array('Content-Type:application/json'),
  13. CURLOPT_ENCODING => "gzip, deflate, br",
  14. CURLOPT_HTTP_VERSION => $_SERVER['SERVER_PROTOCOL'],
  15. CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']
  16. ));
  17.  
  18.  
  19. $output = curl_exec($ch);
  20. $respon = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  21.  
  22. if ($respon == 200) {
  23.  
  24. echo '<script> alert("PHP SUKSES") </script>';
  25. } else {
  26.  
  27. echo '<script> alert("PHP GAGAL") </script>';
  28. }
  29.  
  30. curl_close($ch);
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement