OpenCart 4 php中的API呼叫
我正在尝试在PHP中使用OpenCart 4 API,但我不知道如何正确获取令牌以及如何拨打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中有任何新版本或旧版本中有任何文档,这将非常有帮助。
提前致谢!
I am trying to use OpenCart 4 API in PHP but I can't figure out how to get a token properly and how to make API calls. The documentation is written in Python, so I'm not even able to get a token for authentication.
I managed to get a token for earlier versions using the below code:
$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;
?>
But after I get the token I don't know how to do the actual calls to get the orders and other stuff because there is no documentation for PHP.
In the new version (4.0.0.0) this code gets me an HTML response with a not found page. So does anyone know how to do proper calls in php in the new or old versions. It would be really helpful if there is any documentation in PHP for the new or old versions.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到与以前的版本相比,登录路径已更改。 API/帐户/登录
I see that the login path has changed compared to previous versions. api/account/login