无法使用PHP 7 XML-RPC访问Odoo外部API-拒绝访问,致命错误未捕获Ripcord_TransportException [英] Cannot access to Odoo External API using PHP 7 XML-RPC - Access Denied, Fatal error Uncaught Ripcord_TransportException

查看:91
本文介绍了无法使用PHP 7 XML-RPC访问Odoo外部API-拒绝访问,致命错误未捕获Ripcord_TransportException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PHP 7在我的网站上使用 Odoo的外部API .

I want to use Odoo's External API on my website, using PHP 7.

就像 Odoo的文档所述,我已在我的httpdocs中放置了 Ripcord库.我还已经在服务器上激活了 XML RPC扩展 OpenSSL 已被激活,并且该网站甚至是受保护的(其中有锁定图标地址栏).

Like it is said in the Odoo's documentation, I've placed the Ripcord library in my httpdocs. I have also activated the XML RPC extension on my server, OpenSSL was already activated, and the website is even secured (there's the lock icon in the address bar).

我想在购买许可证之前通过 Odoo演示试用版进行测试.因此,在我的PHP代码中,我输入了与我用于连接username/password rel ="nofollow noreferrer">我的Odoo模拟帐户.

I want to test that with Odoo Demo Trial before we buy licenses. So in my PHP code, I have put the same username/password as the one I used to connect to my Odoo demo account.

1°),但是我得到了 faultCode faultString (访问被拒绝)

1°) But I get faultCode and faultString (Access Denied)

$url = 'https://lgb-test.odoo.com';  // Odoo Demo Trial
$db = 'lgb-test';
$username = 'johndoe@mywebsiteexample.com';  // Same Email as the one to connect to https://lgb-test.odoo.com/web/login
$password = 'mypasswordexample';  // Same Password as the one to connect to https://lgb-test.odoo.com/web/login

require_once('ripcord/ripcord.php');

$common = ripcord::client($url.'/xmlrpc/2/common');
$uid = $common->authenticate($db, $username, $password, array());

echo('UID:');
var_dump($uid);
echo('<br/>');

$models = ripcord::client("$url/xmlrpc/2/object");
$partners = $models->execute_kw(
    $db,
    $uid,
    $password,
    'res.partner',
    'search',
    array(
        array(
            array('is_company', '=', true)
        )
    )
);

echo('RESULT:<br/>');
foreach ($partners as $partner) {
    echo 'partner=['.$partner.']<br/>';
}
 
echo('VAR_DUMP:<br/>');
var_dump($partners);

输出:

UID:bool(false)
RESULT:
partner=[3]
partner=[Access Denied]
VAR_DUMP:
array(2) { ["faultCode"]=> int(3) ["faultString"]=> string(13) "Access Denied" }

2°)当调用 start()方法时,出现致命错误:未捕获的Ripcord_TransportException:无法访问

2°) When the start() method is called, I get Fatal error: Uncaught Ripcord_TransportException: Could not access

require_once('ripcord/ripcord.php');        
$info = ripcord::client('https://lgb-test.odoo.com/start/')->start();

echo 'hello';

输出:

Fatal error: Uncaught Ripcord_TransportException: Could not access https://lgb-test.odoo.com/start/ in /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/ripcord/ripcord_client.php:488 Stack trace: #0 /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/ripcord/ripcord_client.php(228): Ripcord_Transport_Stream->post('https://lgb-tes...', '<?xml version="...') #1 /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/index.php(10): Ripcord_Client->__call('start', Array) #2 {main} thrown in /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/ripcord/ripcord_client.php on line 488

(也许那里有类似的帖子,但有些朦胧:

(Maybe similar posts out there, but somewhat hazy :

如何使用PHP7 Ripcord库获取Odoo数据?.

Odoo + RipcordPHP XMLRPC库:无法访问https://demo.odoo.com/start" )

所以,我仍然不知道真正的问题是什么.

So, I still don't know what the real problem is.

请问有什么想法吗?

推荐答案

1°)经过一段时间的寻找,我最终决定购买一些模块,而不是使用Odoo模拟帐户.

1°) After a while searching for a solution, I finally decided to purchase some modules, instead of using the Odoo Demo account.

因此,我刚刚更改了新数据库的凭据,并打开了该特定URL的8069端口.它起作用了:)

So, I just changed the credentials for my new database, and also opened the 8069 port for that specific URL. And it worked :)

代码:

$url = 'https://thedatabasename.odoo.com';  // Edited here. Opening the 8069 port was the last step to make it work :)
$db = 'thedatabasename';                // Edited here
$username = 'usernameofthataccount';    // Edited here
$password = 'passwordofthataccount';    // Edited here

require_once('ripcord/ripcord.php');

$common = ripcord::client($url.'/xmlrpc/2/common');
$uid = $common->authenticate($db, $username, $password, array());

echo('UID:');
var_dump($uid);
echo('<br/>');

$models = ripcord::client("$url/xmlrpc/2/object");
$partners = $models->execute_kw(
    $db,
    $uid,
    $password,
    'res.partner',
    'search',
    array(
        array(
            array('is_company', '=', true)
        )
    )
);

echo('RESULT:<br/>');
foreach ($partners as $partner) {
    echo 'partner=['.$partner.']<br/>';
}
 
echo('VAR_DUMP:<br/>');
var_dump($partners);

输出:

UID:int(2)
RESULT:
partner=[568]
partner=[570]
partner=[293]
partner=[378]
partner=[526]
VAR_DUMP:
array(193) { [0]=> int(568) [1]=> int(570) [2]=> int(293) [3]=> int(378) [4]=> int(526)}

2°)尽管 start()方法不适用于

因此,我不确定 start()方法是否可以与模拟帐户无关.

So, I'm not sure that the start( ) method will work with something else than a Demo account.

此外,Odoo的支持告诉我不要包含"/开始"脚本中URL的一部分.但是,无论是否带有"/开始"部分,它没有用.

Also, Odoo's support told me to not include the "/start" part of the URL in the script. But, with or without the "/start" part, it didn't work.

代码:

require_once('ripcord/ripcord.php');
$info = ripcord::client('https://thedatabasename.odoo.com/start')->start(); // Even using the specific IP, this is ot working in my case

echo 'hello';

输出:

Fatal error: Uncaught Ripcord_TransportException: Could not access http://102.16.10.74:8069/start/ in /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/ripcord/ripcord_client.php:488 Stack trace: #0 /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/ripcord/ripcord_client.php(228): Ripcord_Transport_Stream->post('http://102.16.1...', '<?xml version="...') #1 /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/index.php(11): Ripcord_Client->__call('start', Array) #2 {main} thrown in /var/www/vhosts/mywebsiteexample.com/preprod.mywebsiteexample.com/ripcord/ripcord_client.php on line 488

我的结论是:

即使我按照此处的说明进行操作,Odoo DEMO也不对我有用:

Odoo DEMO has NOT worked for me, even if I followed the instructions from here :

Odoo的文档

1°)a/当我们将odoo服务器手动安装到其他服务器上时,我们可以获得IP地址(URL类似于"http://xxx.xxx.xxx.xxx").我们选择的主机服务器.

1°) a/ We can get an IP Address (url is like "http://xxx.xxx.xxx.xxx") when we install manually our odoo server onto a different host server of our choice.

1°)b/但是,如果odoo服务器安装在Odoo的官方网站上(URL类似于"https://thedatabasename.odoo.com"),则IP地址.我设法向我网站的网络托管支持打开了8069端口.

1°) b/ But if the odoo server is installed onto Odoo's official website (url is like "https://thedatabasename.odoo.com"), we have no IP Address. And I managed to open the 8069 port by asking for it to the web host support of my website.

为了简单起见,我编辑了"http://xxx.xxx.xxx.xxx"对于 1°)b/的情况,则为"https://thedatabasename.odoo.com":

So, to make it simple, I edited "http://xxx.xxx.xxx.xxx" to "https://thedatabasename.odoo.com", for the case 1°) b/ :

$url = 'https://thedatabasename.odoo.com';
$db = 'thedatabasename';

这篇关于无法使用PHP 7 XML-RPC访问Odoo外部API-拒绝访问,致命错误未捕获Ripcord_TransportException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆