从外部php登录到Odoo

问题描述 投票:0回答:1

当用户已经通过外部php系统进行身份验证时,我想进行自动登录odoo。我正在尝试下面的代码到达这里。

<?php 

    $db = 'cca_second';
    $user = 'admin';
    $passwd = 'westcoast123';

    $data = array(
        'jsonrpc'=> '2.0',
        'params'=> [
            'context'=> [],
            'db'=> $db,
            'login'=> $user,
            'password'=> $passwd,
        ],
    );


    $data_string = json_encode($data);

    $ch = curl_init('http://localhost:8069/web/session/authenticate');                                                                      
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
        'Content-Type: application/json',                                                                                
        'Content-Length: ' . strlen($data_string))                                                                       
    );                                                                                                                   

    $result = curl_exec($ch);

    $result = array(json_decode($result, true));

    $session_id = $result[0]['result']['session_id'];

    var_dump($session_id);

我获得了会话ID,但是我不再知道如何使用它在odoo的浏览器级别上编写cookie,以便一旦重定向到odoo时就不会回到登录页面。

有人可以帮我吗?

谢谢你!

我正在使用odoo 9!

php single-sign-on odoo odoo-9
1个回答
0
投票

Alain Pierre KOUAKOU

请检查此答案Login to Odoo from external PHP system

希望它对您有用。

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.