Created
September 30, 2020 17:31
-
-
Save ceer/b88a5762d293c6b1c27c0664c51e6521 to your computer and use it in GitHub Desktop.
OVH API accept contact change request batch routine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
// Doteenv › composer require vlucas/phpdotenv | |
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | |
$dotenv->load(); | |
// OVH API Wrapper › composer require ovh/ovh | |
use \Ovh\Api; | |
// Get OVH API credentials › https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/* | |
$applicationKey = $_ENV['OVH_API_APP_KEY']; | |
$applicationSecret = $_ENV['OVH_API_SECRET']; | |
$consumer_key = $_ENV['OVH_API_CONSUMER_KEY']; | |
$endpoint = 'ovh-eu'; | |
$ovh = new Api( $applicationKey, | |
$applicationSecret, | |
$endpoint, | |
$consumer_key | |
); | |
// Bash command to create a csv file with id,token based on all confirmation emails | |
// #!/bin/bash | |
// cat *.eml | grep "https://www.ovh.com/manager/\#/useraccount/contacts" | cut -d"/" -f8 | sed "s/?tab=REQUESTS&token=/,/g" > tokens.csv | |
// | |
$csv = array_map('str_getcsv', file('tokens.csv')); | |
foreach ($csv as $row) { | |
$id = $row[0]; | |
$token = $row[1]; | |
$result = $ovh->post('/me/task/contactChange/'.$id.'/accept', array( | |
'token' => $token, | |
)); | |
print_r( $result ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment