public String Post([FromForm] SMSPayload payload) { if (payload != null) { return(payload.message); //return JsonSerializer.Serialize(payload).ToString(); } else { return("Empty"); } }
/// <summary> /// 发送短信 /// </summary> /// <param name="appKey"></param> /// <param name="masterSecret"></param> /// <param name="mobile">手机</param> /// <param name="tempId">模版id</param> /// <param name="msgId">短信码id</param> /// <returns></returns> public static bool Send(string appKey, string masterSecret, string mobile, int tempId, ref string msgId) { bool retBool = false; JSMSClient client = new JSMSClient(appKey, masterSecret); SMSPayload codes = new SMSPayload(mobile, tempId); String codesjson = codes.ToJson(codes); ResponseWrapper ret = client._SMSClient.SendCodes(codesjson); retBool = ret.responseCode == HttpStatusCode.OK; if (retBool) { SendSmsInfo info = JsonConvert.DeserializeObject <SendSmsInfo>(ret.ResponseContent); msgId = info.msg_id; } return(retBool); }
public static void Main(string[] args) { Console.WriteLine("*****开始发送******"); JSMSClient client = new JSMSClient(app_key, master_secret); // 短信验证码 API // API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api SMSPayload codes = new SMSPayload("134888888888", 1); String codesjson = codes.ToJson(codes); Console.WriteLine(codesjson); ResponseWrapper result = client._SMSClient.sendCodes(codesjson); Console.WriteLine("result.responseContent"); Console.WriteLine(result.responseContent); Console.ReadLine(); }
public static void Main(string[] args) { Console.WriteLine("*****开始发送******"); JSMSClient client = new JSMSClient(app_key, master_secret); // 短信验证码 API // API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api_3 Dictionary <string, string> temp_para = new Dictionary <string, string>();; temp_para.Add("codes", "1914"); string para = temp_para.ToString(); Console.WriteLine(para); SMSPayload codes = new SMSPayload("134888888888", 9890, temp_para); String codesjson = codes.ToJson(codes); Console.WriteLine(codesjson); client._SMSClient.sendMessages(codesjson); Console.ReadLine(); }