Пример #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="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);
            }
        }