Home > php教程 > php手册 > 微信公众平台图文消息发布第三方后台实现代码

微信公众平台图文消息发布第三方后台实现代码

WBOY
Release: 2016-06-07 11:35:57
Original
1128 people have browsed it

利用自建页面进行微信公众平台图文消息的发布,多图文的组织,提供预览、群发等功能的实现。
//上传单文案(与微信进行交互,获取其media_id)<br>         public function uploadArticle($id){<br>             /*<br>              * 1、获取封面图片的thumb_media_id<br>              * 2、获取正文中相关图片的url进行替换<br>              * 3、将相关信息存入数据库中<br>              * 4、上传相关信息<br>              */<br>             //实例化单文案表<br>             $local_articles = M('local_articles');<br>             //1、获取封面图片的thumb_media_id(获取封面图片的地址,为website下一固定路径)<br>             $thumb_pic_url = $local_articles->where("id='$id'")->getField('thumb_pic_url');<br>             $thumb_media_id = $this->uploadCoverPic($thumb_pic_url);<br>             //对于微信交互,所有的都进行两次判断和交互。<br>             if(empty($thumb_media_id)){<br>                 $thumb_media_id = $this->uploadCoverPic($thumb_pic_url);<br>             }<br>             $data['thumb_media_id'] = $thumb_media_id;<br>             //2、获取正文中相关图片的url进行替换,换取wx_content<br>             $content = $local_articles->where("id='$id'")->getField('content');<br>             $wx_content = $this->uploadImg($content);<br>             if(empty($wx_content)){<br>                 $wx_content = $this->uploadImg($content);<br>             }<br>             $data['wx_content'] = $wx_content;<br>             //3、将相关信息存入数据库中<br>             $res = $local_articles->where("id='$id'")->data($data)->save();<br>             if(empty($res)){<br>                 $local_articles->where("id='$id'")->data($data)->save();<br>             }<br>             //4、上传相关信息<br>             $media_id = $this->uploadMpnews($id);<br>             if(empty($media_id)){<br>                 $media_id = $this->uploadMpnews($id);<br>             }<br>             return $media_id;<br>         }

附件 WeixinArticleController.class.zip ( 6.75 KB 下载:90 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template