Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. $authorization = "Authorization: Bearer XXXXXXXXXXXXXXXX";
  2. $local_file = 'Report/AzureReport.csv';
  3. $fp = fopen ($local_file, 'w+');
  4. $ch = curl_init($url);
  5. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/Csv', $authorization));
  6. curl_setopt($ch, CURLOPT_FILE, $fp);
  7. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  8. curl_setopt($ch, CURLOPT_ENCODING, "");
  9. curl_exec($ch);
  10. if (!curl_errno($ch))
  11. {
  12. switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE))
  13. {
  14. case 200: echo "ok";# OK
  15. break;
  16. default:
  17. echo 'Unexpected HTTP code: ', $http_code, "n";
  18. }
  19. }else{
  20. echo "error:".curl_errno($ch);
  21. }
  22. curl_close($ch);
  23. fclose($fp);
  24.  
  25.  
  26. output:
  27. error:23
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement