微信公众平台开发小应用:用经纬度坐标位
置查询周围餐厅
// weixin.class.php
classWeixin
{
public $token = ''; //token
public $debug = false; //是否debug的状态标示,方便我们在调试的时候记录一些中间数据
public $setFlag = false;
public $msgtype = 'text'; //('text','image','location')
public $msg = array();
public function __construct($token,$debug)
{
$this->token = $token;
$this->debug = $debug;
}
//获得用户发过来的消息(消息内容和消息类型)
public function getMsg()
{
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
if ($this->debug) {
$this->write_log($postStr);
}
if (!empty($postStr)) {
$this->msg = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$this->msgtype = strtolower($this->msg['MsgType']);
}
}
//回复文本消息
public function makeText($text='')
{
$CreateTime = time();
$FuncFlag = $this->setFlag ?1 : 0;