我正在开发我的角度应用程序,出于某种原因,我想使用opencart REST API。正如文档所述,首先我必须从API获取令牌。来自文档的继承人代码:
import requests
s = requests.Session()
username = 'Default'
key='L3MYyzlYMRL8gBcpCm6CdrVarFUXtPORZkJKP7vgaY8M8EIZWOr3EJxq'
# Actually, key is 256 character-long
s.post(
'http://myopencart.example.com/index.php?route=api/login',
data={'username':username, 'key':key}
).text
这是我的角度应用代码:
getToken() {
return this.http.post(
this.config.getUrl() + '/login',
{
username: this.config.getUserName(),
key: this.config.getKey()
},
{
responseType: 'text'
}
);
}
由于某种原因,我收到此错误消息:
<b>Notice</b>: Undefined index: api_token in <b>/var/www/html/opencart/catalog/controller/startup/startup.php</b> on line <b>45</b><b>Notice</b>: Undefined index: username in <b>/var/www/html/opencart/catalog/controller/api/login.php</b> on line <b>11</b><b>Notice</b>: Undefined index: key in <b>/var/www/html/opencart/catalog/controller/api/login.php</b> on line <b>11</b>[]
我做错了什么?