快闪通知| 短信通知| 语音通知|
接口说明

接口API以REST方式设计,为保证安全性,所有消息交互均以HTTPS方式交互。

所有文档中接口有相同的Base URL,当前为:http://www.iamyun.net:8080/api

业务URL格式:Base URL与业务URL相拼接为完整请求URL,消息参数及返回内容目前只接受json格式。

HTTP消息头:

Accept:application/json;charset=utf-8;

Content-Type:application/json;charset=utf-8;

必须在用户页面编辑好通知模板,通过审核后,用户可以通过接口发送完整的消息。,

通知内容将以通知的形式发送到用户手机

短信通知发送URL:http://www.iamyun.net:8080/api/notice/sms

HTTP方法:POST

公共参数说明

用户注册后登录页面,可以在用户中心看到自己的UID和access token,在所有HTTP请求头中,必须带上此token,如:

Token : xxxxxxxxxxxxxxxxx

用户可以在后续使用中,从页面选择刷新此token,刷新token后,API 调用中的token必须使用新token,原有token自动失效。

为了进一步提高请求安全性,用户可以选择在帐户IP白名单中增加指定IP,只有在白名单中的IP允许访问API。

请求参数说明
参数名 类型 必选 说明 示例
to string 允许多个号码,号码和号码之间英文逗号分隔,最多20个号码 13012345678,1300000000
content string 内容 云上提醒您:您的验证码是:1234,请在1分钟内使用。
report_url string 状态报告发送地址 http://www.example.com/report/
响应参数说明
字段名 类型 说明 示例
status string 调用状态 0
desc string 状态说明 成功
msg_id string 消息ID abcdefghijklmn
示例

POST /notice/sms

{“to”: “13012345678”, “content”: “云上提醒您:您的验证码是:1234,请在1分钟内使用。” }

HTTP/1.1 200 OK

{“status”: “0”, “desc”: “成功”, “msg_id”: “abcd1234efgh”}

代码示例

package com.test;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.util.HashMap;

import java.util.Iterator;

import java.util.Map;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.client.HttpClient;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.entity.StringEntity;

import org.apache.http.impl.client.HttpClientBuilder;

import org.apache.http.protocol.HTTP;

import com.fasterxml.jackson.databind.ObjectMapper;

public class Test {

private static final int HTTP_STATUS_200 = 200;

private static final int HTTP_STATUS_201 = 201;

public static void main(String[] args) throws Exception{

String to = "15xxxxxxxx";

String content = "欢迎您使用我们的服务,【东信昆辰】";

String json ="{\"to\":\""+to+"\",\"content\":\""+content+"\"}";

ObjectMapper objectMapper = new ObjectMapper();

Map headMap = new HashMap ();

headMap.put("Token", "xxxxxxxxxxx");

httpPostHeadWithJSON("http://127.0.0.1:8080/api/notice/sms", json,headMap);

}

public static String httpPostHeadWithJSON(String url, String json,Map headMap) throws Exception {

/* 创建HttpClient实例 */

HttpClient httpClient = HttpClientBuilder.create().build();

HttpPost httpPost = new HttpPost(url);

httpPost.addHeader(HTTP.CONTENT_TYPE, "application/json");

StringEntity se = new StringEntity(json,"UTF-8");

httpPost.setEntity(se);

if (headMap != null) {

for (Iterator it = headMap.keySet().iterator(); it.hasNext();) {

String key = it.next();

String value = headMap.get(key);

httpPost.addHeader(key, value);

}

}

String result = null;

try {

HttpResponse response = httpClient.execute(httpPost);

boolean success = response.getStatusLine().getStatusCode() == HTTP_STATUS_200 ||

response.getStatusLine().getStatusCode() == HTTP_STATUS_201;

HttpEntity entity = response.getEntity();

if (entity != null) {

InputStream instreams = entity.getContent();

result = convertStreamToString(instreams);

}

} catch (Exception e) {

e.printStackTrace();

} finally {

httpPost.releaseConnection();

}

return result;

}

public static String convertStreamToString(InputStream is) {

StringBuilder sb = new StringBuilder();

String line = null;

try {

BufferedReader reader = new BufferedReader(new InputStreamReader(

is, "UTF-8"));

while ((line = reader.readLine()) != null) {

if (sb.length() == 0) {

sb.append(line);

} else {

sb.append("\n" + line);

}

}

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

is.close();

} catch (IOException e) {

e.printStackTrace();

}

}

return sb.toString();

}

}

正在维护更新中...
正在维护更新中...

# coding: utf-8

import requests

# 基地址

base_url = "http://www.iamyun.net:8080/api"

# API接口

req_url = base_url + "/notice/sms"

# HTTP头, 接收JSON格式

headers = {"Content-Type": "application/json;charset=UTF-8"}

# HTTP头中添加访问Token

headers["Token"] = "123456"

# 构造API参数

post_data = {"to": "13018956697", "content": "云上提醒您:您参加了一个重要会议,请您及时参加!"}

# 以json格式POST到服务器

result = requests.post(req_url, json=post_data, headers=headers)

# 得到结果

print result.content

#!/usr/bin/env bash

curl -X POST 'http://www.iamyun.net:8080/api/notice/sms'\

--header "Content-Type:application/json;charset=utf-8;"\

--header "Token: 12345y6"\

-d '{"to": "13588701612", "content": "云上提醒您:您参加了一个重要会议,请您及时参加!"}'

using System;

using System.IO;

using System.Net;

using System.Text;

static class Program

{static void Main()

{

// 基地址

string base_url = "http://www.iamyun.net:8080/api";

// 短信API地址

string req_url = base_url + "/notice/sms";

// 创建请求

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(req_url);

// 请求方法为POST

request.Method = "POST";

// ContentType必须为json

request.ContentType = "application/json;charset=UTF-8";

// 添加Token

request.Headers.Add("Token", "123456");

// 得到请求数据流并添加json格式的post数据,必须是UTF-8编码

Stream myRequestStream = request.GetRequestStream();

StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("utf-8"));

string postDataStr = "{\"to\": \"13018956697\", \"content\": \"云上提醒您:您参加了一个重要会议,请您及时参加!\"}";

myStreamWriter.Write(postDataStr);

myStreamWriter.Close();

// 得到返回内容

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Stream myResponseStream = response.GetResponseStream();

StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));

string retString = myStreamReader.ReadToEnd();

// 关闭流,并打印内容结果

myStreamReader.Close();

myResponseStream.Close();

Console.Write(response.Headers);

Console.Write(retString);

}

}

正在维护更新中...
错误码解释
“做通信,我们是认真的” 云上·通信,十余年通信行业专业团队,为客户提供最优质、最优惠、最简单的互联网新通信服务
立即接入使用