开发者

Error connection to XML-RPC using PHP

I'm having trouble trying to connect to a XML-RPC server in PHP.

The address of the server is constructed like this: https://username:password@example.com/xmlrpc/

I have tried different XML-RPC libraries with no luck, as far as I can see, they fail because of the use of username and password. The examp开发者_JAVA百科les with no username/password authentication encounters no errors and returns the correct results.

How could I retrieve the necessary information from the server?

Best regards

EDIT: I realised that the Zend framework have builtin support for XMLRPC:

<?php
set_include_path($_SERVER['DOCUMENT_ROOT'].'/lib/ZendFramework-1.11.5-minimal/library/');

require_once('Zend/Loader/Autoloader.php'); 
Zend_Loader_Autoloader::getInstance();

define('USERNAME', '*******'); 
define('PASSWORD', '*******'); 
define('LIST_ID', 42);

define('HOSTNAME', 'https://'.USERNAME.'.clients.ubivox.com/xmlrpc/');

$http = new Zend_Http_Client(HOSTNAME, array('keepalive'=>true)); 
$http->setAuth(USERNAME, PASSWORD, Zend_Http_Client::AUTH_BASIC);

$client = new Zend_XmlRpc_Client(HOSTNAME, $http);

try { 
  $response = $client->call('ubivox.get_subscriber', 
                        array('email@user.com'));

  var_dump($response);
} catch (Zend_XmlRpc_Client_FaultException $e) {
  var_dump($e);
}
?>

However unfortunately I'm getting some exceptions, that I'm unable to interpret:

Fatal error: Uncaught exception 'Zend_XmlRpc_Client_HttpException' with message 'UNAUTHORIZED' in /var/www/website/data/www/websitetest.dk/lib/ZendFramework-1.11.5-minimal/library/Zend/XmlRpc/Client.php:288 Stack trace: #0 /var/www/website/data/www/websitetest.dk/lib/ZendFramework-1.11.5-minimal/library/Zend/XmlRpc/Client.php(372): Zend_XmlRpc_Client->doRequest(Object(Zend_XmlRpc_Request)) #1 /var/www/website/data/www/websitetest.dk/test.php(20): Zend_XmlRpc_Client->call('ubivox.get_subs...', Array) #2 {main} thrown in /var/www/website/data/www/websitetest.dk/lib/ZendFramework-1.11.5-minimal/library/Zend/XmlRpc/Client.php on line 288

Does anyone have any clue what I'm doing wrong?


The "XML-RPC for PHP" allows you to connect with the username and password in the URL: http://phpxmlrpc.sourceforge.net/doc-2/ch07s03.html#id934526

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜