Skip to content

Instantly share code, notes, and snippets.

@ceer
Created September 30, 2020 17:31
Show Gist options
  • Save ceer/b88a5762d293c6b1c27c0664c51e6521 to your computer and use it in GitHub Desktop.
Save ceer/b88a5762d293c6b1c27c0664c51e6521 to your computer and use it in GitHub Desktop.
OVH API accept contact change request batch routine
<?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