Giter VIP home page Giter VIP logo

php-ovh's Introduction

OVHcloud APIs lightweight PHP wrapper

PHP Wrapper for OVH APIs

Source Code Build Status Codecov Code Coverage Total Downloads

This PHP package is a lightweight wrapper for OVHcloud APIs.

The easiest way to use OVHcloud APIs in your PHP applications.

Compatible with PHP 7.4, 8.0, 8.1, 8.2.

Installation

Install this wrapper and integrate it inside your PHP application with Composer:

composer require ovh/ovh

Basic usage

<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

// Api credentials can be retrieved from the urls specified in the "Supported endpoints" section below.
$ovh = new Api($applicationKey,
                $applicationSecret,
                $endpoint,
                $consumerKey);
echo 'Welcome '.$ovh->get('/me')['firstname'];

Advanced usage

Handle exceptions

Under the hood, php-ovh uses Guzzle by default to issue API requests.

If everything goes well, it will return the response directly as shown in the examples above.

If there is an error like a missing endpoint or object (404), an authentication or authorization error (401 or 403) or a parameter error, the Guzzle will raise a GuzzleHttp\Exception\ClientException exception. For server-side errors (5xx), it will raise a GuzzleHttp\Exception\ServerException exception.

You can get the error details with a code like:

try {
    echo "Welcome " . $ovh->get('/me')['firstname'];
} catch (GuzzleHttp\Exception\ClientException $e) {
    $response = $e->getResponse();
    $responseBodyAsString = $response->getBody()->getContents();
    echo $responseBodyAsString;
}

Customize HTTP client configuration

You can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests

<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client;

// Instantiate a custom Guzzle HTTP client and tweak it
$client = new Client();
$client->setDefaultOption('timeout', 1);
$client->setDefaultOption('headers', ['User-Agent' => 'api_client']);

// Api credentials can be retrieved from the urls specified in the "Supported endpoints" section below.
// Inject the custom HTTP client as the 5th argument of the constructor
$ovh = new Api($applicationKey,
                $applicationSecret,
                $endpoint,
                $consumerKey,
                $client);

echo 'Welcome '.$ovh->get('/me')['firstname'];

Authorization flow

This flow will allow you to request consumerKey from an OVHcloud account owner. After allowing access to his account, he will be redirected to your application.

See "OVHcloud API authentication" section below for more information about the authorization flow.

use \Ovh\Api;
session_start();

// Api credentials can be retrieved from the urls specified in the "Supported endpoints" section below.
$ovh = new Api($applicationKey,
                $applicationSecret,
                $endpoint);

// Specify the list of API routes you want to request
$rights = [
    [ 'method' => 'GET',  'path' => '/me*' ],
];

// After allowing your application access, the customer will be redirected to this URL.
$redirectUrl = 'https://your_application_redirect_url'

$credentials = $ovh->requestCredentials($rights, $redirectUrl);

// Save consumer key and redirect to authentication page
$_SESSION['consumerKey'] = $credentials['consumerKey'];
header('location: '. $credentials['validationUrl']);
// After successful redirect, the consumerKey in the session will be activated and you will be able to use it to make API requests like in the "Basic usage" section above.

Code sample: Enable network burst on GRA1 dedicated servers

Here is a more complex example of how to use the wrapper to enable network burst on GRA1 dedicated servers.

<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

// Api credentials can be retrieved from the urls specified in the "Supported endpoints" section below.
$ovh = new Api($applicationKey,
                $applicationSecret,
                $endpoint,
                $consumerKey);

// Load the list of dedicated servers
$servers = $ovh->get('/dedicated/server/');
foreach ($servers as $server) {
    // Load the server details
    $details = $ovh->get('/dedicated/server/'.$server);
    // Filter servers only inside GRA1
    if ($details['datacenter'] == 'gra1') {
        // Activate burst on server
        $content = ['status' => 'active'];
        $ovh->put('/dedicated/server/'.$server.'/burst', $content);
        echo 'Burst enabled on '.$server;
    }
}

More code samples

Do you want to use OVH APIs? Maybe the script you want is already written in the example part of this repository!

OVHcloud API authentication

To use the OVHcloud APIs you need three credentials:

  • An application key
  • An application secret
  • A consumer key

The application key and secret are not granting access to a specific account and are unique to identify your application. The consumer key is used to grant access to a specific OVHcloud account to a specified application.

They can be created separately if your application is intended to be used by multiple accounts (your app will need to implement an authorization flow). In the authorization flow, the customer will be prompted to allow access to his account to your application, then he will be redirected to your application.

They can also be created together if your application is intended to use only your own OVHcloud account.

Supported endpoints

OVHcloud Europe

OVHcloud US

OVHcloud North America / Canada

So you Start Europe

So you Start North America

Kimsufi Europe

Kimsufi North America

Building documentation

Documentation is based on phpdocumentor and inclued in the project. To generate documentation, it's possible to use directly:

composer phpdoc

Documentation is available in docs/ directory.

Code check / Linting

Code check is based on PHP CodeSniffer and inclued in the project. To check code, it's possible to use directly:

composer phpcs

Code linting is based on PHP Code Beautifier and Fixer and inclued in the project. To lint code, it's possible to use directly:

composer phpcbf

Testing

Tests are based on phpunit and inclued in the project. To run functionals tests, you need to provide valid API credentials, that you can provide them via environment:

APP_KEY=xxx APP_SECRET=xxx CONSUMER=xxx ENDPOINT=xxx composer phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

All Contributors from this repo

License

(Modified) BSD license. Please see LICENSE for more information.

php-ovh's People

Contributors

amstuta avatar benjamin-hubert avatar benjamin-loison avatar byscripts avatar carsso avatar deathiop avatar dunglas avatar h4cc avatar hedii avatar marema31 avatar peter279k avatar pmachan avatar rbeuque74 avatar shakaran avatar shulard avatar stephanebour avatar stof avatar tekbreak avatar tomschwiha avatar vincentcasse avatar yadutaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-ovh's Issues

Pas de réponse du serveur .

Bonjour,

Je n'ai pas encore acheté de SMS dans cette interface 👍

https://www.ovhtelecom.fr/sms/

Par contre je suis inscrit chez OVH, et j'ai créé 2 tokens ici 👍
https://api.ovh.com/createToken/index.cgi?GET=/sms&GET=/sms/%2a&PUT=/sms/%2a&DELETE=/sms/%2a&POST=/sms/%2a

et ici 👍

https://eu.api.ovh.com/createToken/

Lorsque j'exécute le fichier PHP suivant, je n'ai pas de compte qui s'affiche 👍 en essayant avec les 2 tokens


`<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

session_start();

// Informations about your application
$applicationKey = "xxxxxxxxxxxxxxx";
$applicationSecret = "xxxxxxxxxxxxxxxxxxxx";
$consumer_key = "xxxxxxxxxxxxxxxxxxxxxxxx";
$endpoint = 'ovh-eu';

$conn = new Api(    $applicationKey,
                    $applicationSecret,
                    $endpoint,
                    $consumer_key);
     
$smsServices = $conn->get('/sms/');
foreach ($smsServices as $smsService) {

    print_r($smsService);
}

        
?>`

Par contre le petit programme de connexion marche 👍 et me donne mon nom 👍

`<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

session_start();

// Informations about your application
$applicationKey = "your_app_key";
$applicationSecret = "your_app_secret";
$redirection = "http://your_url.ovh";

// Information about API and rights asked
$endpoint = 'ovh-eu';
$rights = array( (object) [
    'method'    => 'GET',
    'path'      => '/me*'
]);

// Get credentials
$conn = new Api($applicationKey, $applicationSecret, $endpoint);
$credentials = $conn->requestCredentials($rights, $redirection);

// Save consumer key and redirect to authentication page
$_SESSION['consumer_key'] = $credentials["consumerKey"];
header('location: '. $credentials["validationUrl"]);
...
?>` 

Donc je voudrais savoir si c'est parce que j'ai pas acheté de SMS que ça marche pas et que j'ai une blank page, sans erreur ?

This order can't be paid with paypal

Hello,
My problem may not be strictly related to this package, but maybe someone can help. I am currently working on an interface for my team to create new domains, request new service, etc...
Everything is ok but payment, my current workflow is:

  1. Create a cart
  2. Add new services
  3. Set required config fields
  4. Assign the cart to logged in user
  5. Checkout
  6. Try to pay via PayPal

At this point, I get an error. The error is:
403 ActionImpossible This order can't be paid with paypal

My request is as follow:
$request = [ "paymentMean" => "paypal", "paymentMeanId" => XXXXXXX ];
sent to
/me/order/MY_ORDER_ID/payWithRegisteredPaymentMean

I have a valid PayPal account attached to my OVH account and it is used for auto-renewals through OVH. Can I use it via API?

Thanks for your time!

Tagged release

Could you please tag a release so that we can target a specific release in composer?

Thx!

400 Bad Request - INVALID_SIGNATURE

Bonjour,
J'utilise depuis longtemps l'API afin de faire différentes tâches, et mes tâches échouent depuis quelques jours. J'ai essayé de mettre à jour l'API, toujours la même erreur.

Que voici :
Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST https://eu.api.soyoustart.com/1.0/ip/127.0.0.1%2F29/reverse resulted in a 400 Bad Request response: {"errorCode":"INVALID_SIGNATURE","message":"Invalid signature","httpCode":"400 Bad Request"} ' in /var/www/vhosts/azertyuiop.fr/httpdocs/.composer/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/vhosts/azertyuiop.fr/httpdocs/.composer/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/vhosts/azertyuiop.fr/httpdocs/.composer/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/vhosts/azertyuiop.fr/httpdocs/.composer/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/vhosts/azertyuiop.fr/httpdocs in /var/www/vhosts/azertyuiop.fr/httpdocs/.composer/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

En attente d'une correction,
Rapide, je l'espère...
Merci à vous.

Issue with /ip/x.x.x.x/reverse (get/post)

Hello,

im getting this issue only with this part of the API.

The test code is:

require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

$ovh = new Api( $applicationKey,
               $applicationSecret,
               $endpoint,
               $consumer_key);

$rango = 'x.x.x.x/aa';
$ip = 'y.y.y.y';
$ptr = 'servet.domain.tld';

$result = $ovh->post('/ip/'. $rango .'/reverse', array(
   'ipReverse' => $ip,
   'reverse' => $ptr,
));

$result1 = $ovh->get('/ip/'.$rango.'/reverse/'.$ip);

print_r( $result );
print_r( $result1 );

But I always get this error:

PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: GET https://api.ovh.com/1.0/ip/x.x.x.x/aa/reverse/y.y.y.y resulted in a 404 ObjectNotFound response:\n{"message":"Got an invalid (or empty) URL"}\n' in /home/admin/web/testing.domain/public_html/modules/addons/ModuloRaiola/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:107\nStack trace:\n#0 /home/admin/web/testing.domain/public_html/modules/addons/ModuloRaiola/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))\n#1 /home/admin/web/testing.domain/public_html/modules/addons/ModuloRaiola/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))\n#2 /home/admin/web/testing.domain/public_html/modules/addons/ModuloRaiola/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHa in /home/admin/web/testing.domain/public_html/modules/addons/ModuloRaiola/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 107

"errorCode":"INVALID_CREDENTIAL","httpCode":"403 Forbidden","message":"This credential is not valid"

Hi,

I'm working with laravel 5.2 and PHP 7, and after I generate my api_keys and api_secrete from https://eu.api.ovh.com/createApp/, when a try to implemente them in the code I've got from this repositorie, I get the same error message:

ClientException in RequestException.php line 111:
Client error: `GET https://api.ovh.com/1.0/me` resulted in a `403 Forbidden` response:
{"errorCode":"INVALID_CREDENTIAL","httpCode":"403 Forbidden","message":"This credential is not valid"}

My code:

$ovh_key = config('services.ovh.api_key');
$ovh_secret = config('services.ovh.api_secret');
$endpoint = 'ovh-eu';

if(is_null(session('consumer_key'))){
    $redirection = "redirect_url";
    $rights = array( (object) [
        'method'    => 'GET',
        'path'      => '/me*'
    ]); 

    // Get credentials
    $conn = new Api($ovh_key, $ovh_secret, $endpoint);
    $credentials = $conn->requestCredentials($rights, $redirection);
    //dd($credentials);
    // Save consumer key and redirect to authentication page
    session()->put('consumer_key',$credentials["consumerKey"]);
    header('location: '. $credentials["validationUrl"]);
}

$ovh = new Api( $ovh_key,  // Application Key 
        $ovh_secret,  // Application Secret
        $endpoint,      // Endpoint of API OVH Europe (List of available endpoints)
        session('consumer_key')); // Consumer Key 

dd($ovh->get('/me')) //try to access one of the console commands(https://api.ovh.com/console/) ;

Any idea why the error message? Thanks

[QUESTION] Renew domains

I am checking some operation in the API Console about domains.

For me it is very useful the authInfo, unlock, owo, etc. But it would be a lot useful if I could renew the domains in some way, adding even a money balance to my account or so.

Would be available this at some point, so I can automatize the domain renovations? Other domain providers offers an API for this, and I see a lack of feature on OVH, but I would like stay with OVH too if this gets implemented.

Set ssh key on VPS order

It's no option about ssh key when ordering VPS, so no way to connect it from script after order (see #90).
Seems the only workaround is to reinstall VPS before use with /vps/{serviceName}/reinstall.
If ssh key can be set on reinstall, I guess it should be possible to set it when ordering VPS, right?

Bad response on GET with params

$client->get('/order/cart/'.$cartId.'/domain', ['domain' => $domain]); 

résulte en une jolie 400 :

Client error: GET https://api.ovh.com/1.0/order/cart/977c98a2-7841-4b2d-b385-948ef3e49b51/domain?domain=google.com resulted in a 400 Bad Request response: {"errorCode":"INVALID_SIGNATURE","httpCode":"400 Bad Request","message":"Invalid signature"}

Pourtant,

$client->get('/order/cart/'.$cartId.'/domain?domain='.$domain); 

fonctionne.

C'est la même url de reqûete qui est généré, je suppose que le soucis est dans le calcule de la signature dans le client.

Why using grunt a JS tool in a full PHP project ?

Hello !

I discovered that I need to install a node module to be able to test that full php project... I really don't understand why ? It's just too much complexity to just run phpunit, phpcs and phplint...
The complexity which it requires is just useless. Why not using a PHP build tool like Phing to perform the automation ?

How to add another paths

$endpoint = 'ovh-eu'; $rights = array( (object) [ 'method' => 'GET', 'path' => '/me*' ]);
How to add another paths ?

I've tried this:
$endpoint = 'ovh-eu'; $rights = array( (object) [ 'method' => 'GET', 'path' => '/me*', 'path' => '/cloud*' ]);

but didn't work?

Timeouts on requestPromised()

I do not see anything in the documentation talking about timeouts.

Sometimes, my request sent to OVH never returns. That prevent me from either calling the .then() or the .catch(), resulting in a never ending request.

It would be great if there was a way to add a timeout that would fail the request after a certain amount of time, let's say 3 minutes.

Let me know !

This order can't be paid with PAYPAL

Hello,

I am trying to order a service via the OVH API. I can retreive my paypal account id as follows:
$resp = $this->apiv6->get('/me/paymentMean/paypal');
OR I can retreive a registered payment method ID by:
/me/order/{orderId}/paymentMethods

I tried both IDs to work with PayPal. I also tried working with PAYPAL or paypal enum with no happy endings.
I don't understand why OVH doesn't let me use paypal as a payment gateway? I would really appreciate help as I am definitely stuck at the moment and OVH support isn't very responsive about API (understandable).

Thank you.

INVALID_SIGNATURE

Hello, i have an error that i dont understand. I used the php-ovh api in my symfony project and after several try i always have the error : "errorCode":"INVALID_SIGNATURE","httpCode":"400 Bad Request","message":"Invalid signature" in return of my request. I post the little code i have made in the hope that someone can help me :

`<?php

namespace AppBundle\Service;

use Ovh\Api;

class Ovh
{
private $apiAccess;

public function __construct($applicationKey, $applicationSecret, $endpoint)
{
	$this->apiAccess = new Api($applicationKey,
		$applicationSecret,
		$endpoint
	);
	$result = $this->apiAccess->post('/auth/credential', array(
		'accessRules' => array(
			array("method" => "GET", "path" => "/domain/zone")
		)
	));
	//$consumerKey = $this->apiAccess->requestCredentials(array(array('method' => 'GET', 'path' => '/ip')));
	//$consumerKey = $this->apiAccess->requestCredentials(array(array('method' => 'GET', 'path' => '/domain/zone')));
	$this->apiAccess = new Api($applicationKey,
		$applicationSecret,
		$endpoint,
		$result['consumerKey']
	);
}

public function getZoneDns($zone)
{
	$result = $this->apiAccess->get('/domain/zone');
	var_dump($result);
}

}`

No files

Hello, get API access kvmipJnlp:

$result = $ovh->post('/dedicated/server/my_server/features/ipmi/access', array(
    'ipToAllow' => 'my_ip', // IP to allow connection from for this IPMI session (type: ipv4)
    'ttl' => '15', // Required: Session access time to live in minutes (type: dedicated.server.CacheTTLEnum)
    'type' => 'kvmipJnlp', // Required: IPMI console access (type: dedicated.server.IpmiAccessTypeEnum)
));

then get access to the app:

$result = $ovh->get('/dedicated/server/my_server/features/ipmi/access', array(
    'type' => 'kvmipJnlp', // Required: IPMI console access (type: dedicated.server.IpmiAccessTypeEnum)
));

all accesses are created but no jump samango application, ie lacking of a folder in which should lie the script itself:

http://joxi.ru/EA46bKDswxeo7m
http://joxi.ru/82Qq4eGijdewY2

Tell me how to solve this problem?

Problems on Put&Post

I try two things

the first one is Put the rescueMail to server i use the following command
$content = (object) array(
"rescueMail"=> "[email protected]"
);
print_r($content);
$servers = $conn->put('/dedicated/server/'.$servername.'', $content);

i get back a void "1" , after get server details the rescuemail is empty.

Second

Trying to send content to install/start but i get a error on guzzlehttp

my command

$content = (object) array ("templateName"=> $os,
"postInstallationScriptLink"=> "http://www.xxxx.com/script.sh",
"postInstallationScriptReturn"=>"bash script.sh");

                        $servers = $conn->post('/dedicated/server/'.$servername.'/install/start', $content);

hope anyone can help

Alter Mailing List Property

It seems that this call laucnh a new task. However, the result of the call is void.
As such, there is no way to control the execution of this new task.
Is there a way to improve this API ?
(it seems that void return is the rule for any Put call, why ?)

Another point: the documentation available on https://api.ovh.com/console/#/email/domain/{domain}/mailingList/{name}#PUT is incorrect.
$result = $ovh->put('/email/domain/{domain}/mailingList/{name}'); does not provide the new properties and is not in line with the prototype of the function.

Guzzle HTTPClient throwing unnecessary exceptions

When trying to communicate with the OVH.eu API often exceptions (e.g. 404) are thrown.

For example on "GET /ip/{ip}/reverse/{ipReverse}" it returns a message and a 404. By default Guzzle throws exceptions rendering all own code totally useless. The message cannot be evaluated and the code stops executing.

Using OVH PHP API

Hi!

I'm trying to make simple GET request to test how this API works. I have used many days for this but still haven't got this to work.

So I have Application Key, Application Secret and Consumer Key (with granted permissions to /*) and I have downloaded all the decencies (php-ovh-2.0.1-with-dependencies). I have correctly changed correct keys to example codes but they still are not working. I have tested keys with ovh python and that's simple, they are working. With all the examples on the page I get server error:

The * page isn’t working

  • is currently unable to handle this request.

My ovh hosting is using PHP 5.4 and when using this page: https://api.ovh.com/console/ I can use all the GET reguest and they are working. Am I missing something or how this works? I don't have composer on my page.

I can't retrieve the ID of a task using the PHP API

Hi,

Today i've started working with the OVH API to do a project to get finished my studies.

I'm trying to create a subdomain using the mentioned API, and it works (it create the subdomain). But however I can't retrieve the returned data that contains the ID with the "post" function, when I return the value of the variable $task, I'm getting always a null object.

To handle all the process i've build a custom class called OVHAPI, next i'll left the code that i've builded:

<?php

	require_once 'libs/php-ovh/vendor/autoload.php';

	use \Ovh\Api;
	use GuzzleHttp\Client;

	class OVHAPI {

	    private $application_key;
		private $application_secret;
		private $consumer_key;
		private $ovh;
		private $http_client;

	    function __construct() {
	    	require("ovh_conexion.php");

	    	$this->http_client = new Client([
				'timeout'         => 30,
				'connect_timeout' => 5,
			]);

	    	$this->ovh = new Api($this->application_key,
                $this->application_secret,
                'ovh-eu',
                $this->consumer_key,
                $this->http_client
            );
	    }

	    function __destruct() {
	        
	    }

	    function createSubdomain($sub_domain, $zone="cocohost.tk", $field_type="A", $target="149.56.108.120") {
	    	$task = $this->ovh->post('/domain/zone/'.$zone.'/record', array(
			    'fieldType' => $field_type,
			    'subDomain' => $sub_domain,
			    'target' => $target,
			    'ttl' => 'NaN'
			));

			$this->ovh->post('/domain/zone/'.$zone.'/refresh');

			return $task;
	    }
	}

?>

Registering domain

Is is possible to register domain by one post command?

Currently I need to do all these steps:

  • create cart
  • add domain to cart
  • assign cart to user
  • get item id of the domain in cart
  • configure item details
  • checkout
  • pay

[Modify Api.php and DYNHost]: Correct path in php to use in GET/POST/DELETE functions of /ip/{ip}/

This fantastic story is about how fantastic OVH has developed its proprietary programming in APIs. Terribly sad part of this story is how little OVH provided user friendly interface, examples or support until today. The example scripts provided are just not sufficient.

Only after a torturous playing with /Ovh/Api.php and firewall.php (created based on default php code from API website, code unchanged) with correct details to login, I found sending an input to /ip/{ip}/firewall/{ipOnFirewall}/rule from my server is useless as it contains dots in the URI query string (from an IP Address).

More details are here:

Get PHP to stop replacing '.' characters in $_GET or $_POST arrays?

https://stackoverflow.com/questions/68651/get-php-to-stop-replacing-characters-in-get-or-post-arrays

One solution is to have Api.php classes modified to convert dots into underscores at client, when it transmits the query string with dots. Thereafter, the receiving server reconverts the changed query string back into IPs, if underscores are found in /firewall parsing of strings. An advantage is that there is no vulnerability in this system.

Second solution is to provide clients a proper functioning php script. In the API, one finds proper php codes after login. They contain dots from IPs. Due to this "DOT in URL" nothing works.

Because OVH APIs provided those php codes, I thought that this problem of dots is taken care of. This is not the case. The script can login and fetch some data from the API path /me. But it does not do anything when an API call is made under php to /ip/{ip}. It gets stuck with dots in {ip} and throws an error with some explanation one takes time to understand .

One of the best solution is to provide a DYNHost function integrated with /ip/{ip}/firewall that could constantly feed in the actual IP of subdomain under DYNHost to sequence 0 every day. A customer could choose under DYNHost if the latest IP should be inserted into /ip/{ip}/firewall/{ipOnFirewall}/rule/{0}. By doing so, all customers shall have their Routers IP automatically inserted into Rule 0 of all firewalls.

In the absence of the above DYNHost function, all clients are required to undergo a torturous deleting and creating IP under Rule 0 for each firewall by making ten - 15 clicks. Had it been there, a customer could bind services to a specific IP, which could then bind and route to a customer's Router IP. With this system, a customer could have secure access to admin services at non-public and non-standard ports directly bound to his Router IP every day. This increases security and ease to use firewall as all admin services are accessible to a customer's Router IP.

Thus, the suggestion is here not only to [Modify Api.php] but also create an extra API for DYNHost function.

Bad request for DELETE /telephony/{billingAccount}/service/{serviceName}

Bonjour Vincent,

lors de l'appel à DELETE /telephony/{billingAccount}/service/{serviceName} j'ai un 400 Bad Request avec le message INVALID_SIGNATURE quelque soit les droits du token utilisé (DELETE sur /*) sur ce SDK (fonctionne sur d'autres SDK php avec les mêmes paramètres)
Avez-vous une idée de l'origine du blocage?
Merci
Alexandre

Make a new release

Hi, please make a new release to have the latests commits via composer. Thanks

v2.0.1 : 33 commits to master since this release

Problem with parameters (On private database - POST)

Hello,

I've try to create a new private database, but there is an internal problem. API returns Received not described parameters: (serviceName). But I set the parameter :

$servers = $conn->post('/hosting/privateDatabase/lsXXXXXX-001/database', array(
	'serviceName' => "clients",
	'databaseName' => "clients"
));
print_r($servers);

So I also try :

$servers = $conn->post('/hosting/privateDatabase/lsXXXXXX-001/database', (object)array(
	'serviceName' => "clients",
	'databaseName' => "clients"
));
print_r($servers);

And I get :

PHP Fatal error:  Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://api.ovh.com/1.0/hosting/privateDatabase/lsXXXXXX-001/database` resulted in a `400 InvalidArgument` response:
{"message":"Received not described parameters: (serviceName) while calling creation handler"}
 in /tmp/api/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /tmp/api/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /tmp/api/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /tmp/api/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /tmp/api/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /tmp/api/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promi in /tmp/api/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

Thanks ;)

How can I get the price of planCode ?

Is it possible to get the monthly price of each planCode?

When I create a new cloud instance through api I would like to recover the monthly price. It's possible ?
I did not find anything similar yet.

Multiple access rules

Hi, I'l like to create a Token for both GET and POST methods but i don't find the right way to do it
How would the $rights look like with multiple methods ?
Thank you.

SOLVED :

i used

$ovh = new Api(APP_KEY, APP_SECRET, APP_ENDPOINT);
$credentials = $ovh->post('/auth/credential', array(
'accessRules' => array(
array("method" => "GET","path" => "/"),
array("method" => "POST","path" => "/
"),
array("method" => "PUT","path" => "/"),
array("method" => "DELETE","path" => "/
")
),
'redirection' => $redirection,
));
etc ....

Hope it will help.

peace

easily generate restricted rights

hello,

i write those few lines, maybe you could integrate it on a debug mode ?

it shows on the syslog the exaustive calls from the application

$pathstared= preg_replace("/[0-9a-f]{32}/i","*",$path);
$pathstared= preg_replace("/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/","*",$pathstared);
syslog(LOG_INFO,"${method}=${pathstared}&");

output on syslog:

 GET=/cloud/project/*/instance&
 GET=/cloud/project/*/ip/failover&
 GET=/status/task&
 POST=/cloud/project/*/ip/failover/*/attach&
 GET=/me&
 GET=/cloud/project/*/instance&
 GET=/cloud/project/*/ip/failover&

we can then easily generate restricted rights for the app

egrep 'GET|POST|DELETE|PUT' /var/log/syslog|egrep -v 'auth/time|ERROR'|cut -d' ' -f6|sort|uniq|tr -d "\n"

the goal is of course to create keys for just what is necessary
https://api.ovh.com/createToken/index.cgi?GET=/cloud/project/*/instance&GET=/cloud/project/*/ip/failover&GET=/me&GET=/status/task&POST=/cloud/project/*/ip/failover/*/attach&

DELETE order cart error

Good, at this moment I am in a client area for my web, where I plan to offer all the dedicated, clouds and OVH domains for my clients.
In the integration, I am carrying out the shopping cart and I have overcome the problem of removing the domain, the cart from the OVH through the API, obtaining an error.

DELETE https://api.ovh.com/1.0/order/cart/f9fca869-999c-411b-a5da-dfd25c8a6f57/item/62261689
resulted in a `403 Forbidden` response:
{"errorCode":"NOT_GRANTED_CALL","httpCode":"403 Forbidden","message":"This call has not been granted"}

I have verified the data I send and they are correct, in fact since the tool in the documentation works for me. I'm using the api's PHP SDK to make the DELETE request and I get that error, it's the point where my clients remove a domain from their cart, so I must also remove it from the cart in OVH.

The credentials to connect to OVH are not wrong, since I use the same instance with which I add things to the cart.

Regards

Can't create new cart - invalid ovhSubsidiary

When I try same variables at api.ovh.com it works but in my php application i get invalid ovh subsidiary exception.

$result = $ovh->post('/order/cart', array(
'' => '{"description":"5","ovhSubsidiary":"NL"}', // Request Body (type: order.cart.Creation)
));

print_r( $result );

ERROR;

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://api.ovh.com/1.0/order/cart resulted in a 400 Bad Request response: {"class":"Client::BadRequest","message":"invalid ovhSubsidiary"

Error generating docs in Mac Os X 10.13.6

PHP 7.2.13 (cli)

  1. Clone git clone https://github.com/ovh/php-ovh.git
  2. cd php-ovh && composer update # (Some issues on shell)
  3. Try to generate docs
 abkrim@iMac-2  ~/Sites/php-ovh   master  vendor/bin/phing phpdocs
Buildfile: /Users/abkrim/Sites/php-ovh/build.xml

ovh/ovh > clean:

   [delete] Deleting directory /Users/abkrim/Sites/php-ovh/docs

ovh/ovh > phpdocs:

    [mkdir] Created dir: /Users/abkrim/Sites/php-ovh/docs

BUILD FAILED
Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@JMS\Serializer\Annotation\Type" in property phpDocumentor\Configuration::$title does not exist, or could not be auto-loaded. in /Users/abkrim/Sites/php-ovh/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54
Stack trace:
#0 /Users/abkrim/Sites/php-ovh/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(734): Doctrine\Common\Annotations\AnnotationException::semanticalError('The annotation ...')
#1 /Users/abkrim/Sites/php-ovh/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(663): Doctrine\Common\Annotations\DocParser->Annotation()
#2 /Users/abkrim/Sites/php-ovh/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(354): Doctrine\Common\Annotations\DocParser->Annotations()
#3 /Users/abkrim/Sites/php-ovh/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(254): Doctrine\Common\Annotations\DocParser->parse('/**\n     * @var...', 'property phpDoc...')
#4 /Users/abkrim/Sites/php-ovh/vendor/jms/serializer/src/Metadata/Driver/AnnotationDriver.php(154): Doctrine\Common\Annotations\AnnotationReader->getPropertyAnnotations(Object(ReflectionProperty))
#5 /Users/abkrim/Sites/php-ovh/vendor/jms/metadata/src/MetadataFactory.php(107): JMS\Serializer\Metadata\Driver\AnnotationDriver->loadMetadataForClass(Object(ReflectionClass))
#6 /Users/abkrim/Sites/php-ovh/vendor/jms/serializer/src/GraphNavigator/DeserializationGraphNavigator.php(163): Metadata\MetadataFactory->getMetadataForClass('phpDocumentor\\C...')
#7 /Users/abkrim/Sites/php-ovh/vendor/jms/serializer/src/Serializer.php(249): JMS\Serializer\GraphNavigator\DeserializationGraphNavigator->accept(Object(SimpleXMLElement), Array)
#8 /Users/abkrim/Sites/php-ovh/vendor/jms/serializer/src/Serializer.php(178): JMS\Serializer\Serializer->visit(Object(JMS\Serializer\GraphNavigator\DeserializationGraphNavigator), Object(JMS\Serializer\XmlDeserializationVisitor), Object(JMS\Serializer\DeserializationContext), Object(SimpleXMLElement), 'xml', Array)
#9 /Users/abkrim/Sites/php-ovh/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Configuration/Loader.php(112): JMS\Serializer\Serializer->deserialize('<?xml version="...', 'phpDocumentor\\C...', 'xml')
#10 /Users/abkrim/Sites/php-ovh/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Configuration/Loader.php(62): phpDocumentor\Configuration\Loader->createConfigurationObject('/Users/abkrim/S...', '/Users/abkrim/S...', NULL, 'phpDocumentor\\C...')
#11 /Users/abkrim/Sites/php-ovh/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Configuration/ServiceProvider.php(82): phpDocumentor\Configuration\Loader->load('/Users/abkrim/S...', '/Users/abkrim/S...', 'phpDocumentor\\C...')
#12 /Users/abkrim/Sites/php-ovh/vendor/pimple/pimple/lib/Pimple.php(126): phpDocumentor\Configuration\ServiceProvider->phpDocumentor\Configuration\{closure}(Object(phpDocumentor\Application))
#13 /Users/abkrim/Sites/php-ovh/vendor/pimple/pimple/lib/Pimple.php(83): Pimple::{closure}(Object(phpDocumentor\Application))
#14 /Users/abkrim/Sites/php-ovh/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Application.php(254): Pimple->offsetGet('config')
#15 /Users/abkrim/Sites/php-ovh/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Application.php(67): phpDocumentor\Application->addLogging()
#16 /Users/abkrim/Sites/php-ovh/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Bootstrap.php(62): phpDocumentor\Application->__construct(Object(Composer\Autoload\ClassLoader), Array)
#17 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/tasks/ext/phpdoc/PhpDocumentor2Wrapper.php(181): phpDocumentor\Bootstrap->initialize()
#18 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/tasks/ext/phpdoc/PhpDocumentor2Wrapper.php(256): PhpDocumentor2Wrapper->initializePhpDocumentor()
#19 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/tasks/ext/phpdoc/PhpDocumentor2Task.php(173): PhpDocumentor2Wrapper->run()
#20 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/UnknownElement.php(100): PhpDocumentor2Task->main()
#21 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Task.php(283): UnknownElement->main()
#22 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Target.php(336): Task->perform()
#23 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Target.php(366): Target->main()
#24 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Project.php(898): Target->performTasks()
#25 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Project.php(868): Project->executeTarget('phpdocs')
#26 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Phing.php(723): Project->executeTargets(Array)
#27 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Phing.php(200): Phing->runBuild()
#28 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/classes/phing/Phing.php(347): Phing::start(Array, NULL)
#29 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/bin/phing.php(58): Phing::fire(Array)
#30 /Users/abkrim/Sites/php-ovh/vendor/phing/phing/bin/phing(14): require_once('/Users/abkrim/S...')
#31 {main}
Total time: 0.2090 seconds

Issues when composer update

Package kherge/version is abandoned, you should avoid using it. No replacement was suggested.
Package herrera-io/json is abandoned, you should avoid using it. Use kherge/json instead.
Package herrera-io/phar-update is abandoned, you should avoid using it. No replacement was suggested.

Guzzlehttp v6.0

Many libs require guzzlehttp/guzzle to 6.0. Could you please update your composer.json to

"guzzlehttp/guzzle": ">=4.0"

Set Password for VPS

$result = $ovh->post('/vps/{my_vps_name}/setPassword');

return:
This function is not available on your VPS

Client error

with copy & paste i wanted to check X-Frame header options like this :

$client = new Client();
$client->setDefaultOption('timeout', 1);
//$client->setDefaultOption('headers', array('X-Frame-Options' => 'ALLOW'));
$client->setDefaultOption('headers', array('User-Agent' => 'api_client') );

but this give me an error :

PHP Fatal error:  Uncaught TypeError: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, integer given, called in /vendor/guzzlehttp/guzzle/src/Client.php on line 87 and defined in /vendor/guzzlehttp/guzzle/src/Client.php:126
Stack trace:
/vendor/guzzlehttp/guzzle/src/Client.php(87): GuzzleHttp\Client->request('setDefaultOptio...', 'timeout', 1)
#1 loadKey.inc.php(10): GuzzleHttp\Client->__call('setDefaultOptio...', Array)
#2 content.php(5): include('/var/www/html/c...')
#3 {main}
  thrown in /var/www/html/ceph3us.pl/pad/mgm/srv/vendor/guzzlehttp/guzzle/src/Client.php on line 126

Provide an alternative to setPassword

Hi,

The /vps/{serviceName}/setPassword method returns this on my VPS (SSD1-2018):
"This function is not available on your VPS"

From the OVH support:

Cet appel API est déprécié. Il est désormais proposé pour les VPS 2014.

I guess it was deprecated for security reasons, but API should provide an alternative way to set password, or at least any other way to connect in ssh from script to VPS newly ordered with API.

I agree to contribute with a PR but I need help.

I really don't want my script to fetch mails to obtain password, it would be very ugly!

Regards

a way to get a ready to deploy archive

If i use a web hosting pro
i have a lot of difficulty to deplay php-ovh wrapper

how to install/deploy php-ovh
i've just a ftp access to the webserver

i'm surprise to not find easely an archive ready to deploy
may i build an archive on a vps virtual server and use it on my web hosting pro ?

Response too short

When a domain is added to the secondary dns, the message is truncated.
This makes it impossible to know the value of "ownercheck" to take any further action.

Please give examples regarding responder

Dear community,

In the past, we could give OVH-NIC to anybody and with the managerV3 they were able to deal with the responders of their own email address. This is not possible anymore with the new manager, but you can delegate the whole email management to a NIC. This NIC could be used to connect through the API and deal with those responders.

Then, we could imagine this kind of script:

  1. user give the left part of his email address
  2. he receives an email with a forged link to the script server (with a key that identifies himself)
  3. he fills most of the fields requested for creating a responder but not its email address as we already knows who he is (authentified by email)
  4. the script connects with the NIC authorized to manage email and create the responder, then confirms the creation to the user

We could imagine another script to remove any responder linked with an address.

Maybe OVH could help giving example for the 4th point.

Regards,

Domain invalid signature

Hi,

I am always getting this error when I try to use domains:

Client error: `POST https://eu.api.ovh.com/1.0/domain/zone/mydomain.tld/record` resulted in a `400 Bad Request` response:
{"errorCode":"INVALID_SIGNATURE","httpCode":"400 Bad Request","message":"Invalid signature"}

My API keys are correct. If I use the IP API for example, everything is working fine.

[transferLockStatus] Given data (available) does not belong to the DomainLockStatusEnum enumeration

I am trying to update a domain for change the transferLockStatus (to disable or unlock).

I use the following code according to spec in php:

$domain = 'mydomain.es';
try
{ 
	$domain_status = $ovh->put('/domain/' . $domain, ['transferLockStatus' => 'available']);
}
catch (GuzzleHttp\Exception\ClientException $e)
{
	$content = json_decode($e->getResponse()->getBody()->getContents());

	if(isset($content->message))
	{
		echo $content->message . PHP_EOL;
	}
	else 
	{
		echo 'Unknown error message' . PHP_EOL;
	}
}

As result I get:

[transferLockStatus] Given data (available) does not belong to the DomainLockStatusEnum enumeration

I don't know which are the valid values, since DomainLockStatusEnum is not defined in any part in the spec docs. I try passing FALSE with the following code:

try
{ 
	$domain_status = $ovh->put('/domain/' . $domain, ['transferLockStatus' => FALSE]);
}
catch (GuzzleHttp\Exception\ClientException $e)
{
	$content = json_decode($e->getResponse()->getBody()->getContents());

	if(isset($content->message))
	{
		echo $content->message . PHP_EOL;
	}
	else 
	{
		echo 'Unknown error message' . PHP_EOL;
	}
}

Which produces:

Lock unavailable for your domain

So as far I understand the "unlock" feature is not implemented for the TLD ".es". This is possible to perform via OVH web interface, but not for the OVH API, so I would like request this feature, since the purpose of the API is facilitate and automate all this process. Also, I would like a better description of enum values in the OVH API console, because I am clueless to implement properly the scripts.

Problem deleting some domain types

Hi,

I'm using the api from my webpage for creating and deleting records of some domains in ovh, but the las few weeks I have problems deleting.

I have problems deleting some register types like SRV.

This is my sample script in php using your sdk:

The code in pastebin:
https://pastebin.com/eV8iQuy3

get('/domain/zone/mydomain.com/record?fieldType=SRV&subDomain=_sip._udp.mysubdomain'); print_r($response); // this returns 1 record id, for example 1583058551 // delete record $response = $ovh->delete('/domain/zone/mydomain.com/record/1583058551'); print_r($response); ?>

If I execute the script:

The execution in pastebin:
https://pastebin.com/ZPxfZ8GK

php -q test.php
Array
(
[0] => 1583058551
)
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: DELETE https://api.ovh.com/1.0/domain/zone/mydomain.com/record/1583058551 resulted in a 404 Not Found response:
{"message":"The requested object (id = 1583058551) does not exist"}
in /home/test/php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:107
Stack trace:
#0 /home/test/php/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/test/php/vendor/guzzlehttp/promises/src/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/test/php/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /home/test/php/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /home/test/php/vendor/g in /home/test/php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 107

I'am using the api incorrectly?

Other records like "A" records I can delete, so, It is not a permission problem.

If you need another information, please ask me.

Best regards

Add the option to set a connection timeout

To achieve this, in Api.php, after (line 130):

$http_client = new GClient();

add:

$http_client->setDefaultOption('timeout', XXX);
$http_client->setDefaultOption('connect_timeout', YYY);

Where XXX and YYY are seconds.

requestCredentials() always returns 401

Hi
I have updated library to the latest version and now method requestCredentials() always returns
401 Unauthorized response:
{"message":"You must send your application key to request new credentials"}

Solution:
in file Api.php I moved line #287:
$headers['X-Ovh-Application'] = $this->application_key;
to line #284 (before if statement)

Why requiring Guzzle and not define an abstraction layer based on PSR7

Hello !

You are using a PSR7 compliant lib, Guzzle6.

I want to use your API wrapper in one of my project but my client require PHP5.4. With Guzzle6, you force the use of PHP5.5. I'll need to copy your rawCall method to use the same signature logic but in a new wrapper which match my requirements...

Are you aware of active developed tools to abstract HTTP layer ? Do you know Httplug ?

I you want, I can make a PR to integrate that kind of stuff. It allow more flexibility in the HTTP client used and avoid multiple clients in the same context...

Thanks !

ImapCopy error StructImapCopy Data is not a hash for a complex type

Hi !

I'm having some problems with the api and url email/imapCopy

This is the code (generated by the api website, removed passwords) :

<?php
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

$ovh = new Api( 'xxxx',  // Application Key
                'xxxxx',  // Application Secret
                'ovh-eu',      // Endpoint of API OVH Europe (List of available endpoints)
                'xxxxxx'; // Consumer Key

$result = $ovh->post('/email/imapCopy', array(
    'from' => '{"SSL":"false","password":"xxxxx","serverIMAP":"imap.free.fr","account":"[email protected]"}',
    'to' => '{"SSL":"true","password":"xxxx","serverIMAP":"ssl0.ovh.net","account":"[email protected]"}'
));

When I execute the php file, it returns an exception :

PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST https://api.ovh.com/1.0/email/imapCopy resulted in a 400 InvalidArgument response:
{"message":"[to] StructImapCopy Data is not a hash for a complex type"}
' in /home/imapcopy/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111
Stack trace:
#0 /home/imapcopy/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/imapcopy/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/imapcopy/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /home/imapcopy/vendor/guzzlehttp/promises/src/TaskQueue.php(61): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /home/imapcopy/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleH in /home/imapcopy/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 111

Can someone tell me why ? I'm stuck :(

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.