We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

soAPI


jonlewi5
09-06-2010, 20:14
Cheers very much for your help and patiance, at least i can see how it all works now. Thanks.

Myatu
09-06-2010, 20:05
Glad you got it working

RapidSpeeds
09-06-2010, 14:48
Nice one Myatu, spot on as always.

jonlewi5
09-06-2010, 03:05
Haha yeah i guess this is the perfect time to fiddle with the cloud so i can quickly delete and try again.

Thanks so so much for your help though!

EDIT

AHA
Yip, it was something with my setup, just setup a vm and tested, now getting
Code:
login successfull

array(0) {
}
Thanks very much myatu!

Oh well bed time now haha THANKS!!

Myatu
09-06-2010, 03:01
You've baffled me. I just tried it on another machine (PHP 5.3.2, clean install) and worked without modification... Must be getting late

jonlewi5
09-06-2010, 02:44
hmm same error again.

And im not getting any errors in my logs either?

Sorry to be a pain haha

Myatu
09-06-2010, 02:39
Hmm, try commenting out

PHP Code:
if ( !$session 
  throw new 
Exception('Could not create a session'); 
and

PHP Code:
 if ( !$result 
  throw new 
Exception ('Could not get a list of domains'); 
... It probably doesn't like doing a check like that on an object (I did say it was Quick and Dirty )

jonlewi5
09-06-2010, 02:26
Ahh yeah, i see what you mean.

The error is
Code:
Oh crap: Object id #2
Iv double checked phpinfo and im getting
Code:
OpenSSL support 	enabled
OpenSSL Version 	OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
Code:
soap
Soap Client 	enabled
Soap Server 	enabled

Directive	Local Value	Master Value
soap.wsdl_cache	1	1
soap.wsdl_cache_dir	/tmp	/tmp
soap.wsdl_cache_enabled	1	1
soap.wsdl_cache_limit	5	5
soap.wsdl_cache_ttl	86400	86400
Im sure itll be something my end

Thanks very much

Myatu
09-06-2010, 02:19
Quote Originally Posted by jonlewi5
Goes straight to "oh crap"
Haha! It'll tell you what the error was right after that. You probably don't have the SOAP module enabled/compiled in - check with

PHP Code:
(); ?>

jonlewi5
09-06-2010, 02:15
Cheers again myatu.

Goes straight to "oh crap"

Must be something my end, guess i should give up and have another crack at it tomorow

Thanks very much.

Myatu
09-06-2010, 02:03
Here's a quick & dirty example, using PHP5. Note that you need to have the SOAP and OpenSSL modules available.

PHP Code:

try {
 
/* Do we have the required stuff
  * For example in Windows' php.ini: extension=php_soap.dll and extension=php_openssl.dll
  */
 
if ( !class_exists('SoapClient') )
   throw new 
Exception('No SOAP client available.');

 
$soap = new SoapClient('https://www.ovh.com/soapi/soapi-re-1.10.wsdl');

 
// Use SOAPI function "login" to create a session in "en"glish:
 
$session $soap->login('yourid1234-ovh''NotSoSecretPa$$word''en');
 
 
// Did we get a session ID?
 
if ( !$session )
  throw new 
Exception('Could not create a session');

 
// We got a session ID if we reach this point    
 
echo "login successfull\n";

 
// Use SOAPI function "domainList" to get a list of our domains with OVH:
 
$result $soap->domainList($session);
 
 
// And was this function call successful?
 
if ( !$result )
  throw new 
Exception ('Could not get a list of domains');

 
// Yes it was, dump what we've received:
 
echo "
";

 
var_dump($result);
 echo 
"
"
;

 
// Close the session using the "logout" SOAPI function:
 
$soap->logout($session);

} catch(
Exception $error) {
 
// We reach this in case there's been an error
 
echo "Oh crap: " $error;
}

?>
You can easily wrap this into a generic function, or even a class if you wish.

Another note: OVH will send you e-mails on each login/session. You can change this behaviour from the OVH Manager.

PS: Word of advice: try not hardcoding the password

jonlewi5
09-06-2010, 01:11
Just wondering if someone could post some example code using the ovh soapi in php.

Im just trying to get my head around it and am struggling

Thanks.

Jon