短信验证码
简介:代发短信验证码,默认签名为(点睛数据)
接口代码:message 已接入应用数:1 接口状态:关闭
接口价格: 0 元/次 接口服务商:点睛数据 申请 测试 接口请求地址示例:api.djapi.cn/message/get 请求接口的方式: GET        POST
参数名 参数说明 可选值 备注 必填项
mobile 手机号码 11为手机号码,只支持国内3大手机运营商用户
code 验证码 你服务器后台生成的验证码(6位数以内)
cn_to_unicode 汉字Unicode转码 1
0
本设置是对服务器返回数据时是否对中文汉字进行unicode转码,为增强兼容性,默认以unicode转码
token 密匙 请输入您的token密匙
datatype 返回的数据类型 json
xml
json/xml 可选,默认为json格式
通用返回结果
参数名 参数说明 备注
ApiName 接口代码
ErrorCode 返回0或1,0代表无错误,1代表错误,代码不为0时注意查看ErrorReason
ErrorReason 请求失败原因,“no” 代表无错误,正常返回数据
本接口返回的数据( Result )
参数名 参数说明 备注
Mobile 目标手机号码 您查询的快递单号
SendStatus 发送结果 1为发送成功,0为发送失败
Error 发送失败原因 发送成功返回0,发送失败返回对应原因
  • PHP
  • ASP.NET
  • Python
  • JAVA
  • 极简方式

<?php
	header('Content-Type:text/html;charset=utf-8');
	date_default_timezone_set('PRC');
	class apidemo
	{
		public $apipath='api.djapi.cn/message/get';
		public $params;
		public function __construct($params){
			$this->params=http_build_query($params); 
			return $this->get();
		}

		public function get($post_array)
		{
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $this->apipath);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $this->params);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			$result = curl_exec($ch);
			curl_close($ch);
			return $result;
		}
	}

	$post_array = array(
	    'mobile' => '1380XXXXXXX'
	    'code' => '123456'
	    'cn_to_unicode' => '1'
	    'token' => 'XXXXXX'
	    'datatype' => 'json'
	    
	);
	$result=new apidemo($post_array);
	echo '数据返回如下:'.PHP_EOL;
	var_dump($result);

	
//点睛数据:短信验证码,使用ASP.NET方式调用接口简单示例
using System;
using System.Collections.Generic;
using System.Net.Http;
namespace apidemo
{
    public partial class djapi
    {
        public static string apipath = "http://api.djapi.cn";
        public static string get(string mobile,string code,string cn_to_unicode,string token,string datatype)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(apipath);
			var content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("mobile", mobile), new KeyValuePair<string, string>("code", code), new KeyValuePair<string, string>("cn_to_unicode", cn_to_unicode), new KeyValuePair<string, string>("token", token), new KeyValuePair<string, string>("datatype", datatype) });
            var result = client.PostAsync("/message/get", content).Result;
            string resultContent = result.Content.ReadAsStringAsync().Result;
            return resultContent;
        }

    }
    public class test{
	public static string mobile = "1380XXXXXXX";
	public static string code = "123456";
	public static string cn_to_unicode = "1";
	public static string token = "XXXXXX";
	public static string datatype = "json";
	
        static void Main(string[] args)
        {
            string res = djapi.get(citycode, cityname_ch, cityname_py, ip, jwd, cn_to_unicode, token, datatype);
            Console.WriteLine(res);
            Console.Read();
        }
    }
}




#点睛数据:短信验证码,使用Python方式调用接口简单示例
import http.client,urllib.parse
class apidemo:
    apipath="api.djapi.cn"
    apiuri="/message/get";
    def get(self,paramslist):
        params = urllib.parse.urlencode(paramslist)
        headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
        conn = http.client.HTTPConnection(self.apipath)
        conn.request('POST', self.apiuri, params, headers)
        response = conn.getresponse()
        return  response.read()
mobile = "1380XXXXXXX"
code = "123456"
cn_to_unicode = "1"
token = "XXXXXX"
datatype = "json"

data = apidemo.get(apidemo,{"mobile" = mobile,"code" = code,"cn_to_unicode" = cn_to_unicode,"token" = token,"datatype" = datatype})
print(data)




/**
 *点睛数据:短信验证码,使用JAVA方式调用接口简单示例
 * @author 点睛数据
 *          djapi.cn
 */
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class apidemo {
	public static final String mobile = "1380XXXXXXX";
	public static final String code = "123456";
	public static final String cn_to_unicode = "1";
	public static final String token = "XXXXXX";
	public static final String datatype = "json";
	
    public static void main(String[] args) {

        try {
            URL url = new URL("http://api.djapi.cn/ipaddr/get");
            HttpURLConnection connect = (HttpURLConnection)url.openConnection();
            connect.addRequestProperty("encoding","UTF-8");
            connect.setDoInput(true);
            connect.setDoOutput(true);
            connect.setRequestMethod("GET");//POST or GET
            OutputStream output = connect.getOutputStream();
            OutputStreamWriter outputstreamreader = new OutputStreamWriter(output);
            BufferedWriter writer = new BufferedWriter(outputstreamreader);

            // 发送 请求
            String params="&mobile="+mobile+"&code="+code+"&cn_to_unicode="+cn_to_unicode+"&token="+token+"datatype="+datatype;
            writer.write(params);
            // 强制清空缓冲区 输出数据
            writer.flush();

            // 设置好 输入流 -- 因为 只有发送数据之后才会有接收数据
            InputStream inputstream = connect.getInputStream();
            InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
            BufferedReader bufferreader = new BufferedReader(inputstreamreader);

            // 上述步骤将数据封装好之后 即可将数据读取出来了
            String outputstring;
            StringBuilder strbuilder = new StringBuilder();
            while((outputstring=bufferreader.readLine())!= null){
                    strbuilder.append(outputstring);
            }

            writer.close();
            bufferreader.close();
            output.close();
            outputstreamreader.close();
            inputstream.close();
            inputstreamreader.close();

            System.out.println(strbuilder);

        } catch (MalformedURLException e) {
                e.printStackTrace();
        } catch (IOException e) {
                e.printStackTrace();
        }
    }
}
	
//点睛数据:短信验证码,使用极简方式调用接口示例
//直接使用浏览器直接打开如下链接:
api.djapi.cn/message/get?mobile=1380XXXXXXX&code=123456&cn_to_unicode=1&token=XXXXXX&datatype=json
//结果直接在浏览器中输出
	
								
返回结果示例(JSON格式)
示例0


点睛数据
https://djapi.cn

© 2017-2022 深圳市点睛网络有限公司 版权所有   粤ICP备15037691号-2 粤公网安备-44030502001414号