新增图文素材

  public ActionResult Index()
        {


            articles_DTO ato = new articles_DTO();


            List<_articles> alist = new List<_articles>();
            _articles ar = new _articles();
            ar.title = "图文标题";
            ar.thumb_media_id = "Y9rlpsfwqqi0p1dTVfGA4J7yVu52JYbTEjw97u9Tmxo"; //永久media_id图片
            ar.author = "作者";
            ar.show_cover_pic = 1;
            ar.content = "图文内容";
            ar.content_source_url = "www.baidu.com";//跳转路径
            alist.Add(ar);


            ato.articles = alist;






            //序列化
            JsonSerializerSettings jss = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
            string js = JsonConvert.SerializeObject(ato, jss);






            StringContent sc=new StringContent(js);
         
            HttpClient hc = new HttpClient();


            //调用接口
            string url = string.Format(@"https://api.weixin.qq.com/cgi-bin/material/add_news?access_token={0}", Access_token_Tool.access_token);


            //获取返回值
            string str = hc.PostAsync(url, sc).Result.Content.ReadAsStringAsync().Result;
            
            return View();
        }


实体类:
public class articles_DTO
    {
        public List<_articles> articles { get; set; }  
    }


    public class _articles 
    {
        public string title { get; set; }
        public string thumb_media_id { get; set; }
        public string author { get; set; }
        public int show_cover_pic { get; set; }
        public string content { get; set; }
        public string content_source_url { get; set; }
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我会为你介绍php微信的新增永久素材的详细介绍,基本流程如下: 1. 获取access_token 首先,需要通过微信公众平台接口获取access_token,用于后续操作的身份验证。获取access_token可以通过以下接口: ``` https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET ``` 其中,APPID和APPSECRET需要替换成自己的微信公众平台账号对应的AppID和AppSecret。 2. 上传素材 接下来,需要使用上一步获取到的access_token,调用素材上传接口,上传需要添加的素材。可以通过以下接口实现上传: ``` https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE ``` 其中,ACCESS_TOKEN为上一步获取的access_token,TYPE为素材的类型,可选值为image、voice、video和thumb。 3. 获取素材ID 上传素材后,会返回一个素材ID,需要记录下来,用于后续获取素材信息或修改素材。可以通过以下接口获取素材ID: ``` { "media_id":MEDIA_ID, "url":URL } ``` 其中,MEDIA_ID为上传素材后返回的素材ID,URL为上传素材后返回的素材URL。 4. 管理素材 上传素材后,可以通过以下接口管理素材: ``` https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN ``` 其中,get_material接口用于获取素材信息,del_material接口用于删除素材,update_news接口用于修改图文素材。 以上就是新增永久素材的详细介绍和基本流程,希望能对你有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值