コード例 #1
0
ファイル: SmsApi.php プロジェクト: ovh/php-ovh-sms
 /**
  * Request a new sender
  *
  * @param string $sender      The sender to add
  * @param string $reason      A short and descriptive reason why to add the sender
  * @param string $description A description of the sender
  *
  * @return void
  * @throws \GuzzleHttp\Exception\ClientException     if http request returns an error
  * @throws \Ovh\Exceptions\InvalidParameterException if one parameter is missing or with bad value
  */
 public function addSender($sender, $reason, $description = "")
 {
     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");
     }
     if (!isset($reason)) {
         throw new \Ovh\Exceptions\InvalidParameterException("Reason parameter is empty");
     }
     $parameters = (object) array("sender" => $sender, "reason" => $reason, "description" => $description);
     return $this->conn->post("/sms/" . $this->account . "/senders", $parameters);
 }
コード例 #2
0
$path = 'otherFolder';
// Folder where website files are stored
// Informations about the attached domain (optional)
$cdn = 'none';
// Enable CDN on the attached domain. Can be NULL, 'none' or 'active'
$firewall = 'none';
// 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;
            }
コード例 #3
0
 /**
  * Test if post request on me
  */
 public function testPostRestrictionAccessIp()
 {
     $this->assertNull($this->api->post('/me/accessRestriction/ip', ['ip' => $this->rangeIP, 'rule' => 'deny', 'warning' => true]));
     $this->assertNull($this->api->post('/me/accessRestriction/ip', ['ip' => $this->alternativeRangeIP, 'rule' => 'deny', 'warning' => true]));
 }
コード例 #4
0
ファイル: apiv6.php プロジェクト: Rbeuque74/php-ovh
$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');
    print_r($redirection);
} catch (Exception $ex) {
    print_r($ex->getMessage());
}