全球覆盖

支持全球223个国际及地区(含中国大陆)运营商,每个国家全网覆盖。提供详细的运营商网络名单。

高品质语音线路

快速送达,高品质语音播报,通话流畅、语音清晰。

自定义播报次数及语速

可自定义报语音次数及控制语音播报速度,让用户不再错过内容。

个性化配置

根据您的具体需求设置语音验证的当地号码作为 Call sender,更好的体验及更好的解决方案。

适用场景

“您的验证码是 600352”

语音验证码

API 连接

PaaSoo 国际云通讯平台的 REST API 可以通过 HTTPS 及 HTTP 方式请求,为了保证数据的隐私安全,我们强烈建议您使用 HTTPS 方式请求。

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class ValidVoice {
    //编码格式,发送编码格式统一用UTF-8
    private static String ENCODING = "UTF-8";
    //号码格式验证url
    private static String URI_GET_VALID_VOICE = "https://api.paasoo.cn/voice";
    public static void main(String[] args) throws Exception {
        //参数
        String key = "********";
        String secret = "********";
        String from = "********";
        String to = "********";
        String lang = "********";
        String text = "********";
        String repeat = "********";

        System.out.println(ValidVoice.getValidVoice(key, secret, from, to, lang, text, repeat));
    }

    /**
     *
     * @param key       API账号
     * @param secret    API密码
     * @param from      主叫号码
     * @param to        发送目标号码
     * @param lang      接收方接收语音消息的语言
     * @param text      发送内容
     * @param repeat    消息重复播报,默认一次
     * @return
     * @throws Exception
     */
    private static String getValidVoice(String key, String secret, String from, String to, String lang, String text, String repeat) throws Exception {
        Map params = new HashMap();
        params.put("key", key);
        params.put("secret", secret);
        params.put("from", from);
        params.put("to", to);
        params.put("lang", lang);
        params.put("text", text);
        params.put("repeat", repeat);
        return get(URI_GET_VALID_VOICE, params);
    }

    /**
     * 基于HttpClient 4.X的通用GET方法
     *
     * @param url       提交的URL
     * @param paramsMap 提交<参数,值>Map
     * @return          提交响应
     */
    public static String get(String url, Map paramsMap) throws Exception {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        CloseableHttpResponse response = null;
        InputStream is = null;
        try {
            List params = new ArrayList();
            for (Map.Entry param : paramsMap.entrySet()) {
                NameValuePair pair = new BasicNameValuePair(param.getKey(), param.getValue());
                params.add(pair);
            }
            String str = EntityUtils.toString(new UrlEncodedFormEntity(params, ENCODING));
            HttpGet httpGet = new HttpGet(url + "?" + str);
            response = httpClient.execute(httpGet);
            HttpEntity entity = response.getEntity();
            String result = EntityUtils.toString(entity);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (response != null) {
                try {
                    response.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (httpClient != null) {
                try {
                    httpClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}

import requests
from urllib.parse import urlencode

API = "https://api.paasoo.cn/voice"
params = {
"key": "",
"secret": "",
"from": "",
"to": "",
"lang": "",
"text": "",
"repeat": ""
}

url = API + "?" + urlencode(params)
response = requests.get(url)
print(response.text)
                            
444
查看详细文档>>