支持全球 200 多个国家和地区(含中国大陆)运营商,5 秒响应,实时反馈。
支持全球223个国际及地区(含中国大陆)运营商,每个国家全网覆盖。提供详细的运营商网络名单。
我们尽可能直接与当地的运营商对接,建立快速反馈的沟通渠道,更专业更快速更细致地服务用户。
快速的到达速度,多通道智能分流,杜绝拥堵,毫秒级反应。
平台全方面智能监控,自动警报,智能优化切换,让您高枕无忧。
我们深度了解国际通讯市场,根据您的需求,预先告知您当地国家的要求,更好地规避当地法律法规风险。
华威短信 国际云通讯平台的 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; /** * @author ChenQiaoZhen * @since 2019/2/28 */ public class SendSMS { //编码格式,发送编码格式统一用UTF-8 private static String ENCODING = "UTF-8"; //短信发送url private static String URI_GET_SEND_SMS = "https://api.华威短信.cn/json"; public static void main(String[] args) throws Exception { //参数 String key = "********"; String secret = "********"; String from = "********"; String to = "********"; String text = "********";; System.out.println(SendSMS.getSendSms(key, secret, from, to, text)); } /** *短信发送 * * @param key API帐号 * @param secret API密码 * @param from SenderID * @param to 发送目标号码 * @param text 发送内容 * @return json 格式字符串 * @throws Exception */ private static String getSendSms(String key, String secret, String from, String to, String text) throws Exception{ Mapparams = new HashMap (); params.put("key", key); params.put("secret", secret); params.put("from", from); params.put("to", to); params.put("text", text); return get(URI_GET_SEND_SMS, params); } /** * 基于HttpClient 4.X的通用GET方法 * * @param url 提交的URL * @param paramsMap 提交<参数,值>Map * @return 提交响应 */ public static String get(String url, Map paramsMap) { 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; } }
<?php /** * 短信http接口的PHP代码调用示例 * 基于Apache HttpClient 4.X */ class smsApi{ //编码格式。发送编码格式统一用UTF-8 const ENCODING = "UTF-8"; //短信发送url const URI_GET_SEND_SMS = "https://api.华威短信.cn/json"; //发送记录查询url const URI_GET_SEND_RECORD = "https://api.华威短信.cn/dlr"; //余额查询url const URI_GET_USER_BALANCE = "https://api.华威短信.cn/balance"; //号码格式验证url const URI_GET_VALID_NUMBER = "https://api.华威短信.cn/lookup"; /** *短信发送 * * @param key API帐号 * @param secret API密码 * @param from SenderID * @param to 发送目标号码 * @param text 发送内容 * @return json 格式字符串 */ public static function getSendSms($key, $secret, $from, $to, $text) { $text = urlencode($text); $url = self::URI_GET_SEND_SMS."?key=".$key."&secret=".$secret."&from=".$from."&to=".$to."&text=".$text; return self::geturl($url); } /** *查发送记录信息调用示例 * * @param key API帐号 * @param secret API密码 * @param messageid 发送记录消息ID * @return json 格式字符串 */ public static function getSendRecord($key, $secret, $messageid) { $url = self::URI_GET_SEND_RECORD."?key=".$key."&secret=".$secret."&messageid=".$messageid; return self::geturl($url); } /** *查余额信息调用示例 * * @param key API帐号 * @param secret API密码 * @return json 格式字符串 */ public static function getUserBalance($key, $secret) { $url = self::URI_GET_USER_BALANCE."?key=".$key."&secret=".$secret; return self::geturl($url); } /** *号码格式验证调用示例 * * @param key API帐号 * @param secret API密码 * @param countryCode 待验证手机号码所在国家区号 * @param nationalNumber 待验证的手机号码,不含国家区号 * @return json 格式字符串 */ static function getValidNumber($key, $secret, $countryCode, $nationalNumber) { $number = $countryCode.$nationalNumber; $url = self::URI_GET_VALID_NUMBER."?key=".$key."&secret=".$secret."&number=".$number; return self::geturl($url); } public static function geturl($url){ //$headerArray =array("Content-type:application/x-www-form-urlencoded;",""); $ch = curl_init(); echo $url; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch,CURLOPT_HTTPHEADER,$headerArray); $output = curl_exec($ch); curl_close($ch); print_r($output); //$output = json_decode($output,true); return $output; } } //方式一: //$smsApi = new smsApi(); //方式二: //echo smsApi::getSendSms($_REQUEST['key'],$_REQUEST['secret'],$_REQUEST['from'],$_REQUEST['to'],$_REQUEST['text']); //echo smsApi::getSendRecord($_REQUEST['key'],$_REQUEST['secret'],$_REQUEST['messageid']); //echo smsApi::getUserBalance($_REQUEST['key'],$_REQUEST['secret']); echo smsApi::getValidNumber($_REQUEST['key'],$_REQUEST['secret'],$_REQUEST['countryCode'],$_REQUEST['nationalNumber']); ?>
import requests from urllib.parse import urlencode API = "https://api.华威短信.cn/json" params = { "key": "", "secret": "", "from": "", "to": "", "text": "" } url = API + "?" + urlencode(params) response = requests.get(url) print(response.text)