예제 #1
0
        /// <summary>
        /// 关注时候处理
        /// </summary>
        public string weipaiSubscribe(string openid, int wid)
        {
            BLL.wx_userweixin uwbll = new BLL.wx_userweixin();
            string            wxId  = uwbll.GetwxId(wid);//原始Id

            if (wxId == null || wxId.Trim() == "")
            {
                return("wid参数错误");
            }


            try
            {
                WeiXinPF.BLL.wx_paizhao_setting   setBll = new WeiXinPF.BLL.wx_paizhao_setting();
                WeiXinPF.Model.wx_paizhao_setting model  = setBll.GetModelByWid(wid);
                if (model == null || model.isOpen == false)
                {
                    return("未开启");
                }
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                string url    = model.initApiUrl;// "http://wphoto.betterwood.com:8080/Server/wechat/userinit.action";
                string userid = openid;

                string sourceid  = wxId;// "gh_e2d7eb82cb50"; 该用户的来源,即关注的哪一个微信公众账号)、(微信号)原始ID
                string timestamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString();
                string v         = "2000";
                string signature = "";
                parameters.Add("userid", openid);
                parameters.Add("sourceid", sourceid);
                parameters.Add("v", "2000");
                parameters.Add("timestamp", timestamp);
                signature = GetBizSign(parameters);
                string postParam = "userid=" + userid + "&sourceid=" + sourceid + "&timestamp=" + timestamp + "&v=" + v + "&signature=" + signature;
                string ret       = Utils.HttpPost(url, postParam);

                Dictionary <string, object> dict = MyCommFun.JsonToDictionary(ret);
                string returnCode = dict["returncode"].ToString();
                if (returnCode == "200")
                {
                    //成功
                    WXLogs.AddLog(wid, "微拍用户关注时候的接口", "weipaiSubscribe", "奥尔图微拍接口调用成功了", 1);
                }
                else
                {
                    WXLogs.AddLog(wid, "微拍用户关注时候的接口", "weipaiSubscribe", "奥尔图微拍接口调用失败:" + dict["returnmessage"].ToString(), 0);
                }
                return(returnCode);
            }
            catch (Exception ex)
            {
                WXLogs.AddLog(wid, "微拍用户关注时候的接口", "weipaiSubscribe", "报错:" + ex.Message, 0);
                return(ex.Message);
            }
        }
예제 #2
0
 /// <summary>
 /// 是否为微拍的关键词
 /// </summary>
 /// <param name="keywordsStr">关键词字符串,类似 abc,cda,dds,</param>
 /// <param name="wid">微帐号id</param>
 /// <returns></returns>
 public bool isWeipaiKeyWord(string keywordsStr, int wid)
 {
     WeiXinPF.BLL.wx_paizhao_setting   setBll  = new WeiXinPF.BLL.wx_paizhao_setting();
     WeiXinPF.Model.wx_paizhao_setting setting = setBll.GetModelByWid(wid);
     if (setting == null || setting.isOpen == false || keywordsStr.IndexOf(setting.enterKeyWords + ",") < 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #3
0
        /// <summary>
        /// 处理微拍的程序
        /// </summary>
        /// <param name="keywords"></param>
        /// <returns></returns>
        public string weipai_promptStr(string keywords, int wid)
        {
            string ret = "";

            WeiXinPF.BLL.wx_paizhao_setting   setBll  = new WeiXinPF.BLL.wx_paizhao_setting();
            WeiXinPF.Model.wx_paizhao_setting setting = setBll.GetModelByWid(wid);
            if (setting == null || setting.isOpen == false || setting.enterKeyWords != keywords)
            {
                return("");
            }
            else
            {
                ret = setting.prompt.ToString();
            }
            return(ret);
        }
예제 #4
0
        /// <summary>
        /// 传图片
        /// </summary>
        /// <param name="openid"></param>
        /// <param name="PicUrl"></param>
        /// <returns></returns>
        public string weipaiChuanTuPian(string openid, string PicUrl, int wid)
        {
            BLL.wx_userweixin uwbll = new BLL.wx_userweixin();
            string            wxId  = uwbll.GetwxId(wid);//原始Id

            string returnCode = "";

            WeiXinPF.BLL.wx_logs logBll = new WeiXinPF.BLL.wx_logs();
            try
            {
                WeiXinPF.BLL.wx_paizhao_setting   setBll = new WeiXinPF.BLL.wx_paizhao_setting();
                WeiXinPF.Model.wx_paizhao_setting model  = setBll.GetModelByWid(wid);
                if (model == null || model.isOpen == false)
                {
                    return("");
                }
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                string url       = model.picApiUrl; //
                string userid    = openid;
                string sourceid  = wxId;            // "gh_e2d7eb82cb50"; //该用户的来源,即关注的哪一个微信公众账号)、(微信号)原始ID
                string timestamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString();
                string v         = "2000";
                string downurl   = PicUrl;
                string signature = "";
                parameters.Add("userid", openid);
                parameters.Add("sourceid", sourceid);
                parameters.Add("downurl", downurl);
                parameters.Add("timestamp", timestamp);
                parameters.Add("v", "2000");

                signature = GetBizSign(parameters);
                string postParam = "userid=" + userid + "&downurl=" + downurl + "&sourceid=" + sourceid + "&timestamp=" + timestamp + "&v=" + v + "&signature=" + signature;
                string ret       = Utils.HttpPost(url, postParam);

                Dictionary <string, object> dict = MyCommFun.JsonToDictionary(ret);
                returnCode = dict["returncode"].ToString();

                if (returnCode == "200")
                {
                    //成功
                    WXLogs.AddLog(wid, "微拍传图的接口", "weipaiChuanTuPian", "奥尔图微拍接口调用成功了", 1);
                    WeiXinPF.BLL.wx_paizhao_picinfo   pBll = new WeiXinPF.BLL.wx_paizhao_picinfo();
                    WeiXinPF.Model.wx_paizhao_picinfo pic  = new WeiXinPF.Model.wx_paizhao_picinfo();
                    pic.openid     = openid;
                    pic.picUrl     = PicUrl;
                    pic.createDate = DateTime.Now;
                    pBll.Add(pic);
                    return(dict["mentioninfo"].ToString());
                }
                else
                {
                    WXLogs.AddLog(wid, "微拍传图的接口", "weipaiChuanTuPian", "奥尔图微拍接口调用失败:" + dict["returnmessage"].ToString(), 0);
                    return(dict["returnmessage"].ToString());
                }
            }
            catch (Exception ex)
            {
                WXLogs.AddLog(wid, "微拍传图的接口", "weipaiChuanTuPian", "报错:" + ex.Message, 0);
                return("打印接口报错:" + ex.Message);
            }
        }