Skip to content

上传语音录音文件

GiuFLim edited this page Oct 24, 2023 · 7 revisions

简要描述:

  • 语音群呼上传录音文件接口

请求方式:

  • URL:http://api2.nxcloud.com/api/voiceSms/uploadVoiceFile
  • Method:POST
  • Content-Type: application/x-www-form-urlencoded

参数:

参数名 必选 类型 说明
appkey string 语音应用appkey
secretkey string 语音应用secretkey
filename string 文件名称
content string base64编码的文件内容(base64编码转换可查看最下方JAVA示例代码)

请求示例:

curl --location --request POST 'http://api2.nxcloud.com/api/voiceSms/uploadVoiceFile' \
--data-urlencode 'appkey=asdf' \
--data-urlencode 'secretkey=qwer' \
--data-urlencode 'filename=abc.txt' \
--data-urlencode 'content=qwertyuiopasdfghjkl'

返回示例

 {
    "code": "success",
    "info":"http://xxxx.xxx/xxxx.mp3"
 }
 {
    "code": "102",
    "message":"Account unavailable"
 }

返回参数说明

参数名 类型 说明
code string success: 请求成功,其他:请求失败
info string 上传成功的录音文件地址
message string 失败结果说明

备注

  • base64编码转换示例代码
package com;

import cn.hutool.core.codec.Base64;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Test {

    public static void main(String[] args) {
        File f = new File("c:\\tmp\\2.m4a");
        System.out.println(file2Base64(f));
    }

    public static String file2Base64(File file) {
        if(file==null) {
            return null;
        }
        String base64 = null;
        FileInputStream fin = null;
        try {
            fin = new FileInputStream(file);
            byte[] buff = new byte[fin.available()];
            fin.read(buff);
            base64 = Base64.encode(buff);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fin != null) {
                try {
                    fin.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return base64;
    }
}

简介

短信

语音

云呼叫中心(NXLink)

云呼叫中心(AI自动外呼)

Flash Call

短链

邮件验证码

DID号码

通用

号码检测

WhatsApp

Viber

Zalo ZNS

Super Message API

隐私号(旧)

PNS

坐席(旧版)

AI Agent

Clone this wiki locally