mirror of
https://github.com/ovh/php-ovh.git
synced 2023-11-05 03:20:26 +01:00
Fix typo
Signed-off-by: Vincent Casse <vincent.casse@corp.ovh.com>
This commit is contained in:
parent
aded4f28f7
commit
42c0a43c4b
@ -1,12 +1,12 @@
|
||||
How to get web hosting capabilities using php wrapper?
|
||||
----------------------------------------------------
|
||||
How to create HTTP redirection using php wrapper?
|
||||
-------------------------------------------------
|
||||
|
||||
This documentation will help you to create an HTTP redirection from a subdomain to another domain. Following script include DNS record check and delete record if their will conflict with your redirection!
|
||||
|
||||
## Requirements
|
||||
|
||||
- Having PHP 5.2+
|
||||
- Having a dns record at OVH
|
||||
- Having a DNS zone at OVH
|
||||
|
||||
## Download PHP wrapper
|
||||
|
||||
@ -25,7 +25,8 @@ tar xzvf php-ovh-2.0.0-with-dependencies.tar.gz
|
||||
|
||||
## Create a new token
|
||||
|
||||
You can create a new token using this url: [https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*](https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*). Keep application key, application secret and consumer key to complete the script.
|
||||
You can create a new token using this url: [https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*](https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*).
|
||||
Keep application key, application secret and consumer key to complete the script.
|
||||
|
||||
Be warned, this token is only valid for this script on **/domain/zone/\*** APIs.
|
||||
If you need a more generic token, you may adjust the **Rights** fields at your needs.
|
||||
|
@ -3,23 +3,23 @@ require __DIR__ . '/vendor/autoload.php';
|
||||
use \Ovh\Api;
|
||||
|
||||
// Informations about your application
|
||||
$applicationKey = "your_app_key";
|
||||
$applicationSecret = "your_app_secret";
|
||||
$consumer_key = "your_consumer_key";
|
||||
$applicationKey = "your_app_key";
|
||||
$applicationSecret = "your_app_secret";
|
||||
$consumer_key = "your_consumer_key";
|
||||
|
||||
// Information about API endpoint used
|
||||
$endpoint = 'ovh-eu';
|
||||
$endpoint = 'ovh-eu';
|
||||
|
||||
// Information about your domain and redirection
|
||||
$domain = 'yourdomain.ovh';
|
||||
$subDomain = 'www'; // Here, the redirection will come from www.yourdomain.com
|
||||
$targetDomain = 'my_target.ovh';
|
||||
$type = 'visible'; // can be "visible", "invisible", "visiblePermanent"
|
||||
$domain = 'yourdomain.ovh';
|
||||
$subDomain = 'www'; // Here, the redirection will come from www.yourdomain.com
|
||||
$targetDomain = 'my_target.ovh';
|
||||
$type = 'visible'; // can be "visible", "invisible", "visiblePermanent"
|
||||
|
||||
// Field to set in case of invisible redirection
|
||||
$title = '';
|
||||
$keywords = '';
|
||||
$description = '';
|
||||
$title = '';
|
||||
$keywords = '';
|
||||
$description = '';
|
||||
|
||||
// Get servers list
|
||||
$conn = new Api( $applicationKey,
|
||||
@ -32,14 +32,17 @@ try {
|
||||
// check if dns record are available
|
||||
$recordIds = $conn->get('/domain/zone/' . $domain . '/record?subDomain='. $subDomain );
|
||||
|
||||
foreach ($recordIds as $recordId) {
|
||||
$record = $conn->get('/domain/zone/' . $domain . '/record/' . $recordId);
|
||||
// If subdomain is not defined, we don't want to delete all A, AAAA and CNAME records
|
||||
if ( isset($subDomain) ) {
|
||||
foreach ($recordIds as $recordId) {
|
||||
$record = $conn->get('/domain/zone/' . $domain . '/record/' . $recordId);
|
||||
|
||||
// If record include A, AAAA or CNAME for subdomain asked, we delete it
|
||||
if ( in_array( $record['fieldType'], array( 'A', 'AAAA', 'CNAME' ) ) ) {
|
||||
// If record include A, AAAA or CNAME for subdomain asked, we delete it
|
||||
if ( in_array( $record['fieldType'], array( 'A', 'AAAA', 'CNAME' ) ) ) {
|
||||
|
||||
echo "We will delete field " . $record['fieldType'] . " for " . $record['zone'] . PHP_EOL;
|
||||
$conn->delete('/domain/zone/' . $domain . '/record/' . $recordId);
|
||||
echo "We will delete field " . $record['fieldType'] . " for " . $record['subDomain'] . $record['zone'] . PHP_EOL;
|
||||
$conn->delete('/domain/zone/' . $domain . '/record/' . $recordId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user