我想在我的网站上使用Odoo的外部API,使用PHP 7。
就像Odoo's documentation中所说的,我已经把Ripcord library放在我的httpdocs中,我还在我的服务器上激活了XML RPC扩展,OpenSSL已经激活,网站甚至是安全的(地址栏中有锁图标)。
我想在购买许可证之前用Odoo Demo Trial测试一下,所以在我的PHP代码中,我把username/password
和我用来连接my Odoo demo account的username/password
放在了一起。
- 1 °)**但我得到了
faultCode
和faultString
(访问被拒绝)
- 1 °)**但我得到了
$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()
方法时,我得到Fatal error: Uncaught Ripcord_TransportException: Could not access
- 2 °)**当调用
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
(可能有类似的帖子,但有点模糊:
如何使用PHP7 Ripcord库获取Odoo数据?
Odoo + Ripcord PHP XMLRPC library: "Could not access https://demo.odoo.com/start")
所以,我还是不知道真正的问题是什么。
你知道吗?
2条答案
按热度按时间pobjuy321#
因此,我只是更改了新数据库的凭据,并且为该特定URL打开了8069端口。
代码:
输出:
因此,我不确定start()方法是否适用于模拟账户以外的其他账户。
而且,Odoo的支持告诉我不要在脚本中包含URL的"/start"部分,但是,不管有没有"/start"部分,它都不起作用。
代码:
输出:
Odoo演示对我没有起作用,即使我从这里按照指示操作:
Odoo's documentation
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/But if the odoo server is installed onto Odoo's official website (url is like "https://thedatabasename.odoo.com"), we haveno IP Address. And I managed to open the 8069 portby asking for it to the web host supportof my website.
So, to make it simple, I edited "http://xxx.xxx.xxx.xxx" to "https://thedatabasename.odoo.com", for the case1°) b/:
z31licg02#
在我的例子中,有大数据被获取,这就是为什么odoo在
JSONRPC
和XMLRPC
上返回访问错误,所以我在执行函数时使用了limit关键字。[“偏移量”=〉1,“限值”=〉50]