我试图在PHP4API中使用OpenCart 4,但我不知道如何正确地获取令牌以及如何进行API调用。文档是用Python编写的,所以我甚至无法获得用于身份验证的令牌。
我使用以下代码成功地获得了早期版本的令牌:
$post = [
'username' => 'Username',
'key' => 'key',
];
$ch = curl_init('http://localhost/index.php?route=api/login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>但是,在得到令牌之后,我不知道如何进行实际的调用来获取订单和其他东西,因为PHP没有文档。
在新版本(4.0.0.0)中,这段代码将为我提供一个HTML响应,其中有一个未找到的页面。因此,在新版本或旧版本中,是否有人知道如何在php中执行适当的调用。如果PHP中有新版本或旧版本的任何文档,这将是非常有帮助的。
提前感谢!
发布于 2022-07-17 13:49:37
我看到,与以前的版本相比,登录路径已经发生了变化。api/account/login
$post = [
'username' => 'Username',
'key' => 'key',
];
$ch = curl_init('http://localhost/index.php?route=api/account/login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
echo $response;https://stackoverflow.com/questions/72703100
复制相似问题