fork download
  1. <?php
  2.  
  3. $ch = curl_init();
  4.  
  5. // Set URL
  6. curl_setopt($ch, CURLOPT_URL, "https://a...content-available-to-author-only...s.com/v1/quotes");
  7. // Return response instead of printing
  8. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  9. // Add API key header
  10. curl_setopt($ch, CURLOPT_HTTPHEADER, [
  11. "X-Api-Key: CQgjxhmszzFMJ5MHD1k98w==9rilJIPYHukqlAX"
  12. ]);
  13.  
  14. $response = curl_exec($ch);
  15.  
  16. if (curl_errno($ch)) {
  17. echo "Error calling API: " . curl_error($ch);
  18. } else {
  19. echo $response;
  20. }
  21.  
  22. ?>
  23.  
Success #stdin #stdout 0.03s 26140KB
stdin
Standard input is empty
stdout
Error calling API: Could not resolve host: api.api-ninjas.com