listAttachedDomains.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. require __DIR__ . '/vendor/autoload.php';
  3. use \Ovh\Api;
  4. use GuzzleHttp\Client;
  5. // Informations about your application
  6. $applicationKey = "your_app_key";
  7. $applicationSecret = "your_app_secret";
  8. $consumer_key = "your_consumer_key";
  9. // Information about API and rights asked
  10. $endpoint = 'ovh-eu';
  11. // Information about your web hosting(compulsory)
  12. $domain = 'mydomain.ovh'; // Web hosting id (often domain order with it)
  13. $http_client = new Client([
  14. 'timeout' => 30,
  15. 'connect_timeout' => 5,
  16. ]);
  17. // Create a new attached domain
  18. $conn = new Api( $applicationKey,
  19. $applicationSecret,
  20. $endpoint,
  21. $consumer_key,
  22. $http_client);
  23. try {
  24. $attachedDomainsIds = $conn->get('/hosting/web/' . $domain . '/attachedDomain');
  25. foreach( $attachedDomainsIds as $attachedDomainsId) {
  26. $attachedDomain = $conn->get('/hosting/web/' . $domain . '/attachedDomain/' . $attachedDomainsId );
  27. print_r( $attachedDomain );
  28. }
  29. } catch ( Exception $ex ) {
  30. print_r( $ex->getMessage() );
  31. }
  32. ?>