You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PHP cURL调用Vadesecure API遇认证错误求排查

问题排查与解决

1. 核心错误:Bearer 拼写错误

你的Authorization请求头中,将认证类型Bearer错误拼写为Baerer——这是导致服务器返回WRONG_PASSWORD_OR_LOGIN的直接原因。服务器无法识别错误的认证类型,会直接判定凭证无效。

正确的Authorization头格式应为:

'Authorization: Bearer '.$token,

2. 其他排查建议

  • 验证token有效性:确认获取的token未过期,且拥有访问eventlog接口的权限。可重新调用认证接口生成新token后重试。
  • 检查accountId合法性:确保$accountId的值属于当前token授权的账号范围,无拼写或格式错误。
  • 清理冗余curl配置:你的代码同时设置了CURLOPT_POST => 1和CURLOPT_CUSTOMREQUEST => "POST",属于冗余配置,保留其中一个即可(推荐保留CURLOPT_POST => 1)。

修正后的完整脚本

$data = array('accountId'=>$accountId, 'pageSize'=>'10', 'pageToGet'=>'0');
$headers = [ 
  'Authorization: Bearer '.$token, // 修正拼写错误
  'Content-type: application/json'
];

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://cloud.vadesecure.com/rest/v3.0/eventlog/list",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => true,
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_POST => 1,
  CURLOPT_POSTFIELDS => json_encode($data),
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_HTTPHEADER => $headers
));
$responseTest = curl_exec($curl);
print_r($responseTest);

内容的提问来源于stack exchange,提问作者Aleks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 04:30:18