fork download
  1. <?php
  2. // Define the endpoint and the data to be posted
  3. $url = "https://a...content-available-to-author-only...e.org/connect/token";
  4. $data = array(
  5. "grant_type" => "password",
  6. "username" => "jonathan.larsen@autocare.org",
  7. "password" => "3MywJmu&G3Hxm8sg4uC",
  8. "client_id" => "37744C6D561F4B8A",
  9. "client_secret" => "eu6X8vyRTX$#",
  10. "scope" => "CommonApis"
  11. );
  12.  
  13. // Initialize cURL
  14. $ch = curl_init();
  15.  
  16. // Set the URL and other options
  17. curl_setopt($ch, CURLOPT_URL, $url);
  18. curl_setopt($ch, CURLOPT_POST, true);
  19. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  20. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  22.  
  23. // Execute the request and fetch the response
  24. $response = curl_exec($ch);
  25.  
  26. // Close cURL
  27.  
  28. // Process the response
  29. if ($response) {
  30. $json_response = json_decode($response, true);
  31. print_r($json_response);
  32. } else {
  33. echo "Error: " . curl_error($ch);
  34. echo "Repsine" .$response;
  35. }
  36. ?>
  37.  
Success #stdin #stdout #stderr 0.03s 26164KB
stdin
Standard input is empty
stdout
Error: Repsine
stderr
PHP Warning:  curl_error(): supplied resource is not a valid cURL handle resource in /home/8d6i3e/prog.php on line 34