1
0
mirror of https://github.com/ovh/php-ovh.git synced 2023-11-05 03:20:26 +01:00
php-ovh/examples/hosting-attachedDomain/api_attach_domain_to_web_hosting.md
Vincent Casse 0378c8db51 Add attached domain example
Signed-off-by: Vincent Casse <vincent.casse@corp.ovh.com>
2016-01-19 11:59:59 +01:00

3.3 KiB

How to attach domains to a web hosting offer using the php wrapper?

This documentation will help you to create, edit and delete domains attached to your webhosting offer. This documentation is the equivalent of MultiDomain SoAPI and SubDomain SoAPI

Compatibility note

MultiDomains and SubDomains features are merged into one feature called Attached Domains. You can manage both with this new feature in OVH APIs.

Requirements

  • Having PHP 5.2+
  • Having a domain at OVH
  • Having an hosting account

Download PHP wrapper

# When this article was written, latest version was 2.0.0
wget https://github.com/ovh/php-ovh/releases/download/v2.0.0/php-ovh-2.0.0-with-dependencies.tar.gz
  • Extract it
tar xzvf php-ovh-2.0.0-with-dependencies.tar.gz 

Create a new token

You can create a new token using this url. Keep the application key, the application secret and the consumer key to complete the script.

Be warned, this token is only valid for this script and for hosting called my_domain. Please replace my_domain by your web hosting reference! If you need a more generic token, make sure to set the rights field to your needs

Attach a domain to your web hosting

When you call the API to attach a domain to your web hosting, the api call returns a task. The task is the current state of an operation to attach this domain to your hosting. The example script explains how to attach a domain an wait the end of the operation.

If this script works, you should see someting like:

Task #42 is created
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'doing'
Domain attached to the web hosting

List all your attached domains

The example script explains how to show all your domains attached to a web hosting For instance, using the example values in this script, the answer could be look like:

Array
(
    [domain] => myotherdomaintoattach.ovh
    [cdn] => none
    [ipLocation] => 
    [ownLog] => myotherdomaintoattach.ovh
    [firewall] => none
    [path] => otherFolder
)

Detach a domain from your web hosting

The example script explains how to detach a domain to your web hosting.

If this script works, you should see someting like:

Task #42 is created
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'todo'
Status of task #42 is 'doing'
Domain detached from the web hosting

What's next?

You can discover all hosting possibilities by using API console to show all available endpoints: https://api.ovh.com/console