全球号码段

验证全球号码格式正确与否,更好的提高发送成功率

提前验证

提前验证用户的号码格式,让用户注册上更加高效,提高激活率。

减少费用损失

通过验证号码格式,减少发送错误号码,为企业减少费用支出。

免费政策

我们为使用我们短信以及语音的服务提供免费号码格式验证API服务。让您海外拓展更加专业。

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 ValidNumber {
    //编码格式,发送编码格式统一用UTF-8
    private static String ENCODING = "UTF-8";
    //号码格式验证url
    private static String URI_GET_VALID_NUMBER = "https://api.paasoo.cn/lookup";

    public static void main(String[] args) throws Exception {
        //参数
        String key = "********";
        String secret = "********";
        String countryCode = "********";
        String number = "********";

        System.out.println(ValidNumber.getValidNumber(key, secret, countryCode, number));
    }

    /**
     *号码格式验证
     *
     * @param key            API帐号
     * @param secret         API密码
     * @param countryCode    待验证手机号码所在国家区号
     * @param number 待验证的手机号码,不含国家区号
     * @return
     * @throws Exception
     */
    public static String getValidNumber(String key, String secret, String countryCode, String number) throws Exception {
        Map params = new HashMap();
        params.put("key", key);
        params.put("secret", secret);
        params.put("countryCode", countryCode);
        params.put("number", number);
        return get(URI_GET_VALID_NUMBER, 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;
    }

}

                                
2222
import requests
from urllib.parse import urlencode

API = "https://api.paasoo.cn/lookup"
params = {
"key": "",
"secret": "",
"number": ""
}

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