/** * Test Api::get */ public function testApiGetWithParameters() { $this->setExpectedException('\\GuzzleHttp\\Exception\\ClientException', '400'); $this->api->get('/me/accessRestriction/ip', ['foo' => 'bar']); }
/** * Get details for a sender * * @param string $sender Sender to get details * * @return mixed * @throws \GuzzleHttp\Exception\ClientException if http request returns an error */ public function getSenderDetails($sender) { if (is_null($this->account)) { throw new \Ovh\Exceptions\InvalidParameterException("Please set account before using this function"); } if (!isset($sender)) { throw new \Ovh\Exceptions\InvalidParameterException("Sender parameter is empty"); } return $this->conn->get("/sms/" . $this->account . "/senders/{$sender}"); }
// Enable HTTP firewall (block dangerous pattern requests with Apache mod_security). Can be NULL, 'active' or 'none' $ownLog = 'myotherdomaintoattach.ovh'; // Separate logs by domain. Can be 'null' or domain offer you have at OVH $http_client = new Client(['timeout' => 30, 'connect_timeout' => 5]); // Create a new attached domain $conn = new Api($applicationKey, $applicationSecret, $endpoint, $consumer_key, $http_client); try { // This call will create a "task". The task is the status of the attached domain creation. // You can follow the task on /hosting/web/{serviceName}/tasks/{id} $task = $conn->post('/hosting/web/' . $domain . '/attachedDomain', array('domain' => $domainToAttach, 'path' => $path, 'cdn' => $cdn, 'firewall' => $firewall, 'ownLog' => $ownLog)); echo "Task #" . $task['id'] . " is created" . PHP_EOL; // we check every 5 seconds if the task is done // When the task disappears, the task is done while (1) { try { $wait = $conn->get('/hosting/web/' . $domain . '/tasks/' . $task['id']); if (strcmp($wait['status'], 'error') === 0) { // The task is in error state. Please check your parameters, retry or contact support. echo "An error has occured during the task" . PHP_EOL; break; } elseif (strcmp($wait['status'], 'cancelled') === 0) { // The task is in cancelled state. Please check your parameters, retry or contact support. echo "Task has been cancelled during the task" . PHP_EOL; break; } echo "Status of task #" . $wait['id'] . " is '" . $wait['status'] . "'" . PHP_EOL; } catch (\GuzzleHttp\Exception\ClientException $ex) { $response = $ex->getResponse(); if ($response && $response->getStatusCode() === 404) { echo "Domain attached to the web hosting" . PHP_EOL; break;
<?php 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"; // Information about API and rights asked $endpoint = 'ovh-eu'; // Information about your web hosting $web_hosting = 'my_domain'; // Get servers list $conn = new Api($applicationKey, $applicationSecret, $endpoint, $consumer_key); $hosting = $conn->get('/hosting/web/' . $web_hosting); print_r($conn->get('/hosting/web/offerCapabilities', array('offer' => $hosting['offer'])));
// 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" // Field to set in case of invisible redirection $title = ''; $keywords = ''; $description = ''; // Get servers list $conn = new Api($applicationKey, $applicationSecret, $endpoint, $consumer_key); try { // check if dns record are available $recordIds = $conn->get('/domain/zone/' . $domain . '/record?subDomain=' . $subDomain); // 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'))) { echo "We will delete field " . $record['fieldType'] . " for " . $record['subDomain'] . $record['zone'] . PHP_EOL; $conn->delete('/domain/zone/' . $domain . '/record/' . $recordId); } } } // Now, we are ready to create our new redirection $redirection = $conn->post('/domain/zone/' . $domain . '/redirection', array('subDomain' => $subDomain, 'target' => $targetDomain, 'type' => $type, 'title' => $title, 'description' => $description, 'keywords' => $keywords)); // We apply zone changes $conn->post('/domain/zone/' . $domain . '/refresh');
<?php require __DIR__ . '/vendor/autoload.php'; use Ovh\Api; use GuzzleHttp\Client; // Informations about your application $applicationKey = "your_app_key"; $applicationSecret = "your_app_secret"; $consumer_key = "your_consumer_key"; // Information about API and rights asked $endpoint = 'ovh-eu'; // Information about your web hosting(compulsory) $domain = 'mydomain.ovh'; // Web hosting id (often domain order with it) $http_client = new Client(['timeout' => 30, 'connect_timeout' => 5]); // Create a new attached domain $conn = new Api($applicationKey, $applicationSecret, $endpoint, $consumer_key, $http_client); try { $attachedDomainsIds = $conn->get('/hosting/web/' . $domain . '/attachedDomain'); foreach ($attachedDomainsIds as $attachedDomainsId) { $attachedDomain = $conn->get('/hosting/web/' . $domain . '/attachedDomain/' . $attachedDomainsId); print_r($attachedDomain); } } catch (Exception $ex) { print_r($ex->getMessage()); }
<?php require dirname(__DIR__) . "/vendor/autoload.php"; use Ovh\Api; $apk1 = "RZKbAlowUCBgoPds"; $endpoint = "ovh-eu"; $ask1 = "mAcXugeOcn2gZBvyb76bKvN1y2gACqmz"; $csk1 = "VTYF8K727bsg42Qn5so76iYb3994jbjp"; $ovh1 = new Ovh\Api($apk1, $ask1, $endpoint, $csk1); $me1 = $ovh1->get("/me"); $apk2 = "nP9Ij0PFvlZw0wV6"; $endpoint = "ovh-eu"; $ask2 = "GpwkoBOZijNgqYFygxyEg2zMSGg4X3pX"; $csk2 = "tGEmEglYpqu2xkdOTM563FAQ3Y9sPJys"; $ovh2 = new Api($apk2, $ask2, $endpoint, $csk2); $me2 = $ovh2->get("/me"); $apk3 = "YDrgCr1VvT3LtVf8"; $endpoint = "ovh-eu"; $ask3 = "eKekzBFbKfWeh3gKB1Fb4n9zXa16D6D2"; $csk3 = "5tQNjCGSfYHdxetHfWORhOvGufGXlFBg"; $ovh3 = new Api($apk3, $ask3, $endpoint, $csk3); $me3 = $ovh3->get("/me"); require_once dirname(__DIR__) . "/classe/user.php"; $user_cls = new user(); $user = $user_cls->info_user($login); require_once dirname(__DIR__) . "/classe/general.php"; $gen_cls = new general(); require_once dirname(__DIR__) . "/classe/paypal.php"; require_once dirname(__DIR__) . "/classe/gestion/client.php"; $client_cls = new client(); require_once dirname(__DIR__) . "/classe/gestion/devis.php";
/** * Test Api::get, should build valide signature */ public function testApiGetWithQueryString() { $this->api->get('/me/api/credential', ['status' => 'pendingValidation']); }
public function call($method, $parameters = null) { $conn = new Api($this->application_key, $this->application_secret, $this->endpoint, $this->consumer_key); return $conn->get($method, $parameters); }