Advertisement
IoanaBdn

Untitled

Jan 24th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public function getCurl($url)
  2. {
  3. $curl = curl_init();
  4.  
  5. curl_setopt_array($curl, array(
  6. CURLOPT_URL => $url,
  7. CURLOPT_RETURNTRANSFER => true,
  8. CURLOPT_ENCODING => "",
  9. CURLOPT_TIMEOUT => 30000,
  10. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  11. CURLOPT_CUSTOMREQUEST => "GET",
  12. CURLOPT_HTTPHEADER => array(
  13. // Set Here Your Requesred Headers
  14. 'public-key: VXGNq3GcR73gNJ2FLN2cMZwHPPujy71yrveK0scORS7KzoXWVyjXjh6vzZ1spvzg',
  15. 'Content-Type: application/json',
  16. ),
  17. ));
  18. $response = curl_exec($curl);
  19. $err = curl_error($curl);
  20. curl_close($curl);
  21.  
  22. if ($err) {
  23. $result = "cURL Error #:" . $err;
  24. } else {
  25. $result = json_decode($response);
  26. }
  27. return $result;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement