Advertisement
AMONRA75

PHP - CURL JSON URL

Mar 30th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. function retrieveJSON($URL) {
  2.         $ch = curl_init();
  3.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  4.         curl_setopt($ch, CURLOPT_HEADER, false);
  5.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  6.         curl_setopt($ch, CURLOPT_URL, $URL);
  7.         curl_setopt($ch, CURLOPT_REFERER, $URL);
  8.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  9.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
  10.         curl_setopt($ch, CURLOPT_TIMEOUT, 60); //timeout in seconds
  11.         $result = curl_exec($ch);
  12.         curl_close($ch);
  13.         $json = json_decode($result, true);
  14.         return $json;
  15.    
  16.        
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement