Ejemplo n.º 1
0
Archivo: WeiboAPI.cs Proyecto: uvbs/mmp
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="url"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public T GetCommand <T>(string data, string url, string method = "get")
        {
            data += "&access_token=" + accessTokenBase;

            string result = string.Empty;

            try
            {
                if (method.Equals("get", StringComparison.OrdinalIgnoreCase) || method.Equals(""))
                {
                    result = m.GetWebRequest(data, url, encodingBase);
                }
                else if (method.Equals("post", StringComparison.OrdinalIgnoreCase))
                {
                    result = m.PostWebRequest(data, url, encodingBase);
                }

                if (result == "[]" || string.IsNullOrWhiteSpace(result))
                {
                    return(default(T));
                }
                return(JsonConvert.DeserializeObject <T>(result));
            }
            catch (Exception ex)
            {
                return(default(T));
                //throw ex;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取短信余额
        /// </summary>
        /// <param name="websiteowner">站点</param>
        /// <returns></returns>
        public bool GetSmsDeposit(string websiteowner, out int deposit, out string msg)
        {
            deposit = 0;
            msg     = "";
            string timeStamp = Math.Round(GetTimeStamp(DateTime.Now), 0).ToString();
            SortedDictionary <string, string> dic = new SortedDictionary <string, string>();

            dic.Add("userName", websiteowner);
            dic.Add("timestamp", timeStamp);
            string sign = CreateSign(timeStamp);

            dic.Add("sign", sign);
            ZentCloud.Common.HttpInterFace request = new Common.HttpInterFace();
            string par    = LinkPar(dic);
            JToken result = JToken.Parse(request.GetWebRequest(par, string.Format("http://{0}/serv/api/sms/status.ashx", ZentCloud.Common.ConfigHelper.GetConfigString("SmsDomain")), Encoding.UTF8));

            if (bool.Parse(result["status"].ToString()))
            {
                deposit = int.Parse(result["result"]["deposit"].ToString());
                msg     = "获取短信余额成功";
                return(true);
            }
            else
            {
                msg = result["msg"].ToString();
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 短信充值
 /// </summary>
 /// <param name="websiteowner">站点</param>
 /// <param name="orderId">订单号</param>
 /// <param name="point">短信条数</param>
 /// <param name="msg">提示消息</param>
 /// <returns></returns>
 public bool SmsRecharge(string websiteowner, string orderId, int point, out string msg)
 {
     msg = "";
     try
     {
         string timeStamp = Math.Round(GetTimeStamp(DateTime.Now), 0).ToString();
         SortedDictionary <string, string> dic = new SortedDictionary <string, string>();
         dic.Add("userName", websiteowner);
         dic.Add("timestamp", timeStamp);
         dic.Add("orderId", orderId);
         dic.Add("point", point.ToString());
         string sign = CreateSign(timeStamp);
         dic.Add("sign", sign);
         ZentCloud.Common.HttpInterFace request = new Common.HttpInterFace();
         string par    = LinkPar(dic);
         JToken result = JToken.Parse(request.GetWebRequest(par, string.Format("http://{0}/serv/api/sms/recharge.ashx", ZentCloud.Common.ConfigHelper.GetConfigString("SmsDomain")), Encoding.UTF8));
         if (bool.Parse(result["status"].ToString()))
         {
             msg = "充值成功";
             return(true);
         }
         else
         {
             msg = result["msg"].ToString();
             return(false);
         }
     }
     catch (Exception ex)
     {
         msg = ex.ToString();
         return(false);
     }
 }
Ejemplo n.º 4
0
        ///// <summary>
        ///// 发送短信 大汉三通
        ///// </summary>
        ///// <param name="mobile">手机号,多个手机号用,分隔</param>
        ///// <param name="message">短信内容</param>
        ///// <param name="sign">短信签名示例【大汉三通】</param>
        ///// <returns></returns>
        //public bool SendSmsdh3t(string mobile, string message, string sign)
        //{
        //    string userId = System.Configuration.ConfigurationManager.AppSettings["DahanSantongUserId"];
        //    string password = System.Configuration.ConfigurationManager.AppSettings["DahanSantongPassword"];
        //    var postData = new
        //    {
        //        account = userId,
        //        password = ZentCloud.Common.DEncrypt.GetMD5(password),
        //        phones = mobile,
        //        content = message,
        //        sign = sign
        //    };
        //    ZentCloud.Common.HttpInterFace request = new Common.HttpInterFace();
        //    string result = request.PostWebRequest(ZentCloud.Common.JSONHelper.ObjectToJson(postData), "http://www.dh3t.com/json/sms/Submit", Encoding.UTF8);
        //    JToken jToken = JToken.Parse(result);
        //    if (jToken["result"].ToString() == "0")
        //    {
        //        return true;
        //    }
        //    return false;


        //}
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="websiteOwner">站点所有者</param>
        /// <param name="mobile">手机号</param>
        /// <param name="message">短信内容</param>
        /// <returns></returns>
        public bool SendSms(string websiteOwner, string mobile, string message)
        {
            //BLLJIMP.BLLUser bllUser = new BLLUser();

            //UserInfo websiteOwnerUserInfo = bllUser.GetUserInfo(websiteOwner, websiteOwner);

            //Common.HttpInterFace webRequest1 = new Common.HttpInterFace();
            //string parm = string.Format("userName={0}&userPwd={1}&mobile={2}&content={3}&pipeID=membertrigger", websiteOwnerUserInfo.UserID, websiteOwnerUserInfo.Password, mobile, message);
            //string returnCode = webRequest1.PostWebRequest(parm, "http://sms.comeoncloud.net/Serv/SubmitSMSAPI.aspx", System.Text.Encoding.GetEncoding("gb2312"));
            //if (!string.IsNullOrEmpty(returnCode) && (returnCode.ToString().Equals("0")))
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}


            //}

            string timeStamp = Math.Round(GetTimeStamp(DateTime.Now), 0).ToString();
            SortedDictionary <string, string> dic = new SortedDictionary <string, string>();

            dic.Add("userName", websiteOwner);
            dic.Add("mobile", mobile);
            dic.Add("content", message);
            dic.Add("pipeID", "membertrigger");
            dic.Add("timestamp", timeStamp);
            string sign = CreateSign(timeStamp);

            dic.Add("sign", sign);
            ZentCloud.Common.HttpInterFace request = new Common.HttpInterFace();
            string par    = LinkPar(dic);
            JToken result = JToken.Parse(request.GetWebRequest(par, string.Format("http://{0}/serv/api/sms/send.ashx", ZentCloud.Common.ConfigHelper.GetConfigString("SmsDomain")), Encoding.UTF8));

            if (bool.Parse(result["status"].ToString()))
            {
                return(true);
            }
            else
            {
                return(false);
            }


            //string userName = "******";
            //string key = System.Configuration.ConfigurationManager.AppSettings["LUOSIMAOKEY"];
            //string url = "http://sms-api.luosimao.com/v1/send.json";
            //byte[] byteArray = Encoding.UTF8.GetBytes("mobile=" + mobile + "&message=" + message);
            //HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
            //string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(userName + ":" + key));
            //webRequest.Headers.Add("Authorization", auth);
            //webRequest.Method = "POST";
            //webRequest.ContentType = "application/x-www-form-urlencoded";
            //webRequest.ContentLength = byteArray.Length;

            //Stream newStream = webRequest.GetRequestStream();
            //newStream.Write(byteArray, 0, byteArray.Length);
            //newStream.Close();

            //HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
            //StreamReader srReader = new StreamReader(response.GetResponseStream(), Encoding.Default);
            //string result = srReader.ReadToEnd();
            //if (result.Contains("\"error\":0"))
            //{
            //    return true;
            //}
            //else
            //{
            //    try
            //    {
            //        using (StreamWriter sw = new StreamWriter(@"D:\SmsLog.txt", true, Encoding.GetEncoding("gb2312")))
            //        {
            //            sw.WriteLine(string.Format("{0}  {1}", DateTime.Now.ToString(), result + message));
            //        }
            //    }
            //    catch { }
            //}
            //return false;
        }