Home > Backend Development > PHP Tutorial > WeChat api graphic message case

WeChat api graphic message case

WBOY
Release: 2016-07-29 09:03:22
Original
1351 people have browsed it
<?php
header(&#39;Content-type: text/html; charset=utf-8&#39;);#设置头信息
require_once(&#39;zhphpWeixinApi.class.php&#39;);#加载微信接口类文件
$zhwx=new zhphpWeixinApi();//实例化
$c
				&#39;token&#39;=>'wxtest1',
				'appid'=>'wx5b79a26868798826',
				'appSecret'=>'a95952819cc768fc130bc0cc0444ae77',
				'myweixinId'=>'gh_746ed5c6a58b'
				);
$zhwx->setConfig($configArr);//配置文件
if($zhwx->validToken()){
	if($zhwx->weixinBaseApiMessage()){
		$keyword=$zhwx->getUserTextRequest();//得到用户发的微信内容
		$msgtype=$zhwx->getUserMsgType();//得到用户发的微信数据类型
		$SendTime=$zhwx->getUserSendTime();//得到用户发送的时间
		 if($msgtype == 'text' && $keyword == 'news'){
		    $newsData=array(
					  array(
					  'Title'=>'第一条新闻的标题',
					  'Description'=>'第一条新闻的简介',
					  'PicUrl'=>'http://t12.baidu.com/it/u=1040955509,77044968&fm=76',
					  'Url'=>'http://wxphptest1.applinzi.com/news.php?id=1'
					  ),
					  array(
					  'Title'=>'第二条新闻的标题',
					  'Description'=>'第一条新闻的简介',
					  'PicUrl'=>'http://images.cnitblog.com/blog2015/340216/201505/051316468603876.png',
					  'Url'=>'http://wxphptest1.applinzi.com//news.php?id=2'
					  ),
			);
				$zhwx->responseMessage('news',$newsData);
			}
	}
}
Copy after login

The above introduces the WeChat API graphic message case, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template