private void setSMSAccountInfo() { try { JSONObject json = JSONConvert.DeserializeObject(getStringBySMSAPI( "http://api.weimi.cc/2/account/balance.html", "uid=" + uid + "&pas="******"&type=json")); if (accountInfo.InvokeRequired) { setAccountInfoThreadDelegate saitd = new setAccountInfoThreadDelegate(setSMSAccountInfo); this.Invoke(saitd, new object[] { }); } else { accountInfo.Text = "账户余额(短信): " + (json["sms-left"]).ToString() + "/" + (json["sms-total"]).ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "获取SMS账户信息错误!"); } }
private void sendSMS() { try { if (!verifyMobileNumbers()) { MessageBox.Show("输入的短信号码错误,请重新验证!", "提示"); } else { /* 微米 weimi.cc * String addtionInfo = ""; * String apiString = "mob=" + mobileNumbers + "&cid=" + cidNumber + "&uid=" + uid + "&pas="******"&type=json"; * if (setTimeCheckBox.Checked) * { * //yyyy-MM-dd HH:mm:ss * apiString += "&timing=" + setTimeDateTimePicker.Value.ToString(setTimeDateTimePicker.CustomFormat); * addtionInfo = "定时(将于" + setTimeDateTimePicker.Value.ToString(setTimeDateTimePicker.CustomFormat) + "发送)"; * } * if (isEnabledDrivers) * { * apiString += "&p1=" + ContactNumber; * } * JSONObject json = JSONConvert.DeserializeObject(getStringBySMSAPI( * "http://api.weimi.cc/2/sms/send.html", * apiString)); * * if (int.Parse((json["code"]).ToString()) == 0) * { * clearReciptNumer(); * MessageBox.Show(addtionInfo + "短信" + mobileNumbers + "发送成功!", "提示"); * } * else * { * MessageBox.Show("短信" + mobileNumbers + "发送失败:(code:" + (json["code"]).ToString() + ")" + (json["msg"]).ToString(), "提示"); * } */ // 聚合数据 juhe.cn String addtionInfo = ""; String apiString = "&mobile=" + mobileNumbers + "&tpl_id=" + cidNumber + "&tpl_value=" + tpl_value + "&dtype=" + "&key=" + uid; if (setTimeCheckBox.Checked) { //yyyy-MM-dd HH:mm:ss apiString += "&timing=" + setTimeDateTimePicker.Value.ToString(setTimeDateTimePicker.CustomFormat); addtionInfo = "定时(将于" + setTimeDateTimePicker.Value.ToString(setTimeDateTimePicker.CustomFormat) + "发送)"; } if (isEnabledDrivers) { apiString += "&p1=" + ContactNumber; } JSONObject json = JSONConvert.DeserializeObject(getStringBySMSAPI( "http://v.juhe.cn/sms/send", apiString)); if (int.Parse((json["error_code"]).ToString()) == 0) { clearReciptNumer(); MessageBox.Show(addtionInfo + "短信" + mobileNumbers + "发送成功!", "提示"); } else { MessageBox.Show("短信" + mobileNumbers + "发送失败:(code:" + (json["error_code"]).ToString() + ")" + (json["reason"]).ToString(), "提示"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "发送SMS错误!"); } }