/v2/bot/publish通过这个接口发布的机器人,怎么所有的回答全部失效了?
就是通过平台的机器人发布,所有回答全部生效,然后通过接口进行发布的机器人,所有的回答就会失效。
我看了自己写的发布接口,也正确返回了的,证明接口应该是没有问题吧。
public function publish(){
// 接口地址
$url = 'https://openaiapi.weixin.qq.com/v2/bot/publish';
// 替换为你的真实Token
$token = $this->getAccessToken();
// 请求体数据
// 生成sign签名
$timestamp = TM;
$nonce = UID;
$bodyStr = '';
$signStr = $this->openaiToken . $timestamp . $nonce . md5($bodyStr);
$sign = md5($signStr);
// 请求头信息
$headers = [
'Content-Type: application/json',
'X-OPENAI-TOKEN: ' . $token,
'request_id: ' . UID, // 生成唯一request_id
'timestamp: ' . $timestamp,
'nonce: ' . $nonce,
'sign: ' . $sign,
];
// 初始化cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 执行cURL请求
$response = curl_exec($ch);
// dump(json_decode($response, true));
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// 检查HTTP状态码
if ($httpCode !== 200) {
return json([
'code' => -1,
'msg' => '请求失败,HTTP状态码:' . $httpCode,
'data' => null,
]);
}
// 解析响应
$result = json_decode($response, true);
if (isset($result['code']) && $result['code'] === 0) {
return true;
} else {
return false;
}
}
您好 请提供下机器人ID,谢谢