ads - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of ads.php

  1. <?php
  2.  
  3. // Auth0 API endpoint to retrieve connections
  4. $auth0_url = 'https://dev-fow9p8vk.us.auth0.com/api/v2/connections';
  5.  
  6. // Auth0 API token
  7. $auth0_token = '63188f37e12aa51fabb7b6dd';
  8.  
  9. // Set up cURL
  10. $ch = curl_init();
  11.  
  12. // Set the cURL options
  13. curl_setopt($ch, CURLOPT_URL, $auth0_url);
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  15. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  16.     'Content-Type: application/json',
  17.     'Authorization: Bearer ' . $auth0_token
  18. ));
  19.  
  20. // Execute the cURL request
  21. $response = curl_exec($ch);
  22.  
  23. // Check for errors
  24. if ($response === false) {
  25.     echo 'cURL error: ' . curl_error($ch);
  26. } else {
  27.     // Decode the JSON response
  28.     $connections = json_decode($response, true);
  29.  
  30.     // Check if connections are retrieved successfully
  31.     if (isset($connections['strategies']) && !empty($connections['strategies'])) {
  32.         // Display the social connections
  33.         echo "Social Connections available:\n";
  34.         foreach ($connections['strategies'] as $strategy) {
  35.             echo $strategy['name'] . "\n";
  36.         }
  37.     } else {
  38.         echo "No social connections found.";
  39.     }
  40. }
  41.  
  42. // Close cURL session
  43. curl_close($ch);
  44.  
  45. ?>
  46.  
File Description
  • ads
  • PHP Code
  • 29 Jan-2024
  • 1.17 Kb
You can Share it: