Ejemplo n.º 1
0
        //发送已存在图文素材的图文消息
        public static void sendOldNews()
        {
            CorpMpnewsMessage ctx = new CorpMpnewsMessage
            {
                touser  = WechatCommonPara.ToUser,
                toparty = "",
                totag   = "",
                mpnews  = new MpNews {
                    media_id = "25HGfQxHkUoJJ7LnVU_YyFR2SAg4JFcysBOzlLUg9JRRLPkUJiEG4T1vh5GAO-fIt"
                },
                safe = 1
            };

            ICropMessage cm     = new CropMessage();
            CommonResult result = cm.SendMessage(ctx);
        }
Ejemplo n.º 2
0
        //发送不存在图文素材的图文消息
        public static void sendMpNews(string mpPic, string mpTitle, string mpAuthor, string mpDigest, string mpContent)
        {
            #region 过期代码


            //{
            //    "touser": "******",
            //    "toparty": " PartyID1 | PartyID2 ",
            //    "totag": " TagID1 | TagID2 ",
            //    "msgtype": "mpnews",
            //    "agentid": 1,
            //    "mpnews": {
            //        "articles":[
            //            {
            //                "title": "Title",
            //                "thumb_media_id": "id",
            //                "author": "Author",
            //                "content_source_url": "URL",
            //                "content": "Content",
            //                "digest": "Digest description",
            //                "show_cover_pic": "0"
            //            },
            //            {
            //                "title": "Title",
            //                "thumb_media_id": "id",
            //                "author": "Author",
            //                "content_source_url": "URL",
            //                "content": "Content",
            //                "digest": "Digest description",
            //                "show_cover_pic": "0"
            //            }
            //        ]
            //    },
            //    "safe":0
            //}

            #endregion

            //1.上传图片
            ICropMaterial icm      = new CropMaterial();
            string        media_id = "";
            CommonResult  result   = null;
            try
            {
                result = icm.Add("image", mpPic, ref media_id);
            }
            catch (Exception ex)
            {
            }

            //2.图文素材清单
            List <MpNewsArticle> lst = new List <MpNewsArticle>()
            {
                new MpNewsArticle {
                    title = mpTitle, thumb_media_id = media_id, author = mpAuthor, content_source_url = "", content = mpContent, digest = mpDigest, show_cover_pic = "1"
                }
            };
            CorpMpnewsMessage ctx = new CorpMpnewsMessage
            {
                touser  = WechatCommonPara.ToUser,
                toparty = "",
                totag   = "",
                mpnews  = new MpNews {
                    articles = lst
                },
                safe = 0
            };
            ICropMessage cm = new CropMessage();
            result = cm.SendMessage(ctx);
        }