<?php include "wechatext.class.php"; global $_W; $rid = 15; $content = $this->message['content']; $from_user = $this->message['from']; $sql = "SELECT * FROM " . tablename('stubind_reply') . " WHERE `weid`=:weid LIMIT 1"; $row = pdo_fetch($sql, array(':weid' => $_W['weid'])); //自动获取用户信息 $options = array('account' => $row['account'], 'password' => $row['password'], 'datapath' => $_W['attachurl'] . 'cookie_'); $wechat = new Wechatext($options); $sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1"; $row_info = pdo_fetch($sql, array(':from_user' => $from_user)); if (!empty($row_info['fakeid'])) { if ($wechat->checkValid()) { $fakeid = $row_info['fakeid']; //fakeid $send = $wechat->send($fakeid, '测试'); $se = json_decode($send, true); if ($se['base_resp']['err_msg'] == 'ok') { return $this->respText('OK'); } else { return $this->respText('NO'); } } }
<?php /** * 微信扩展接口测试 */ include "../wechatext.class.php"; function logdebug($text) { file_put_contents('../data/log.txt', $text . "\n", FILE_APPEND); } $options = array('account' => '*****@*****.**', 'password' => 'demo', 'datapath' => '../data/cookie_', 'debug' => true, 'logcallback' => 'logdebug'); $wechat = new Wechatext($options); if ($wechat->checkValid()) { // 获取用户信息 $data = $wechat->getInfo('3974255'); var_dump($data); // 获取最新一条消息 $topmsg = $wechat->getTopMsg(); var_dump($topmsg); // 主动回复消息 if ($topmsg && $topmsg['hasReply'] == 0) { $wechat->send($topmsg['fakeId'], 'hi ' . $topmsg['nickName'] . ',rev:' . $topmsg['content']); } }
$table = explode('】', $str); $ret = ''; foreach ($table as $k => $v) { if ($k > 0) { $ret .= $v; } } if ($ret == '') { $ret = "亲,你木有借书呀!"; } $err = '亲,图书馆网站的功能出现问题了,无法帮你查询,请反馈信息给图书馆信息技术部~'; if (!empty($row_info['fakeid'])) { if ($wechat->checkValid()) { $fakeid = $row_info['fakeid']; //fakeid $send = $wechat->send($fakeid, $ret); $se = json_decode($send, true); if ($se['base_resp']['err_msg'] == 'ok') { return $this->respText($xh . '请稍等..'); } else { return $this->respText($err); } } } //return $this->respText($ret); /* $string=get_utf8_string($string);//图书馆网站编码GB2312都要转UTF-8方便操作 $string=str_replace('<td width="36" align="center">续满</td>',"<input type="checkbox" value='123'>",$string); preg_match('/<input type="checkbox" (.*?)>(?P<info>.+?)<\/tr>/s', $string, $results); //echo $results['info'];
var_dump($userlist); $user = $userlist[0]; // 获取用户信息 $userdata = $wechat->getInfo($user['id']); var_dump($userdata); // 获取已保存的图文消息 $newslist = $wechat->getNewsList(0, 10); var_dump($newslist); //获取用户最新消息 $topmsg = $wechat->getTopMsg(); var_dump($topmsg); $msglist = $wechat->getMsg(); var_dump($msglist); // 主动回复消息 if ($topmsg && $topmsg['has_reply'] == 0) { $wechat->send($user['id'], 'hi ' . $topmsg['nick_name'] . ',rev:' . $topmsg['content']); $content = '这是一条Wechatext发出的测试微信'; $imgdata = file_get_contents('http://github.global.ssl.fastly.net/images/modules/dashboard/bootcamp/octocat_fork.png'); $img = '../data/send.png'; file_put_contents($img, $imgdata); //上传图片 $fileid = $wechat->uploadFile($img); echo 'fileid:' . $fileid; //if ($fileid) $re = $wechat->sendImage($user['id'],$fileid); //发送图文信息 $re = $wechat->sendPreview($userdata['user_name'], $content, $content, $content, $fileid, 'http://github.com/dodgepudding/wechat-php-sdk'); var_dump($re); //发送视频 //$re = $wechat->sendVideo($user['id'],$fileid); $re = $wechat->getFileList(2, 0, 10); var_dump($re);
$sql = "SELECT * FROM " . tablename('stubind_reply') . " WHERE `weid`=:weid LIMIT 1"; $row = pdo_fetch($sql, array(':weid' => $_W['weid'])); //自动获取用户信息 $options = array('account' => $row['account'], 'password' => $row['password'], 'datapath' => $_W['attachurl'] . 'cookie_'); $wechat = new Wechatext($options); $sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1"; $row_info = pdo_fetch($sql, array(':from_user' => $from_user)); $ret = preg_match('/图书信息(?P<id>.*?)$/i', $this->message['content'], $matchs); $id = $matchs['id']; $bookinfo = bookinfo($id); $err = '亲,图书馆网站的搜索功能出现问题了,无法帮你查询,请反馈信息给图书馆信息技术部~'; if (!empty($row_info['fakeid'])) { if ($wechat->checkValid()) { $fakeid = $row_info['fakeid']; //fakeid $send = $wechat->send($fakeid, $bookinfo); $se = json_decode($send, true); if ($se['base_resp']['err_msg'] == 'ok') { return $this->respText('请稍等..'); } else { return $this->respText($err); } } } function get_utf8_string($content) { $encoding = mb_detect_encoding($content, array('ASCII', 'UTF-8', 'GB2312', 'GBK', 'BIG5')); return mb_convert_encoding($content, 'utf-8', $encoding); } function sqh($sqh) {
$bookname = $idtitle['title'][$key]; $floor = substr($sqh, 0, 1); $floor = sqh($floor); $str = $key + 1 . '.' . $bookname . "\n编号: " . $value . "\n出版年" . $year . "\n索取号" . $sqh . "\n" . $floor . "\n"; //$str='@title|'.($key+1).'.'.$bookname.'、编号: '.$value.'#url|'.$itemurl.'#pic'; $all = $all . $str . "\n"; } } $err = '亲,图书馆网站的搜索功能出现问题了,无法帮你查询,请反馈信息给图书馆信息技术部~'; if ($all != '') { //echo 'description|信息查询#title|图书信息'.$all; if (!empty($row_info['fakeid'])) { if ($wechat->checkValid()) { $fakeid = $row_info['fakeid']; //fakeid $send = $wechat->send($fakeid, $all); $se = json_decode($send, true); if ($se['base_resp']['err_msg'] == 'ok') { return $this->respText('请稍等..'); } else { return $this->respText($err); } } } } else { return $this->respText($err); } function get_utf8_string($content) { $encoding = mb_detect_encoding($content, array('ASCII', 'UTF-8', 'GB2312', 'GBK', 'BIG5')); return mb_convert_encoding($content, 'utf-8', $encoding);