本文实例为大家分享了php微信公众号图书馆的具体代码,供大家参考,具体内容如下
图书来源:山东理工大学图书馆书目检索系统
搜索书名返回是xml格式数据:
核心代码如下:
$postobj = simplexml_load_string($poststr, 'simplexmlelement', libxml_nocdata); $fromurname = $postobj->fromurname; $tourname = $postobj->tourname; $keyword = trim($postobj->content); $time = time(); $texttpl = "<xml> <tourname><![cdata[%s]]></tourname> <fromurname><![cdata[%s]]></fromurname> <createtime>%s</createtime> <msgtype><![cdata[news]]></msgtype> <articlecount>3</articlecount> <articles> <item> <title><![cdata[%s]]></title> <description><![cdata[s]]></description> <picurl><![cdata[url]]></picurl> <url><![cdata[url]]></url> </item> <item> <title><![cdata[%s]]></title> <description><![cdata[s]]></description> <picurl><![cdata[url]]></picurl> <url><![cdata[url]]></url> </item> <item> <title><![cdata[%s]]></title> <description><![cdata[s]]></description> <picurl><![cdata[url]]></picurl> <url><![cdata[url]]></url> </item> </articles> <funcflag>1</funcflag> </xml>"; $url="http://222.206.65.12/opac/arch_rss.php?dept=all&title={$keyword}&doctype=all&lang_code=all&match_flag=forward&displaypg=20&showmode=list&orderby=desc&sort=cata_date&onlylendable=no"; $fa=file_get_contents($url); $f=simplexml_load_string($fa); $da1=$f->channel->item[0]->title; $da2=$f->channel->item[1]->title; $da3=$f->channel->item[2]->title; $resultstr = sprintf($texttpl, $fromurname, $tourname,高中集合 $time,$da1,$da2,$da3);echo $resultstr;
index.php整体代码如下:
<?php/** * wechat php test *///define your tokendefine("token", "weixin");$wechatobj = new wechatcallbackapitest();$wechatobj->responmsg();class wechatcallbackapitest{ public function valid() { $echostr = $_get["echostr"]; //valid signature , option if($this->checksignature()){ echo $echostr; exit; } } public function responmsg() { //get post data, may be due to the different environments $poststr = $globals["http_raw_post_data"]; //extract post data if (!empty($poststr)){ $postobj = simplexml_load_string($poststr, 'simplexipad 16gmlelement', libxml_nocdata); $fromurname = $postobj->fromurname; $tourname = $postobj->tourname; $k写家乡特产的作文eyword = trim($postobj->content); $time = time(); $texttpl = "<xml> <tourname><![cdata[%s]]></tourname> <fromurname><![cdata[%s]]></fromurname> <createtime>%s</createtime> <msgtype><![cdata[news]]></msgtype> <articlecount>3</articlecount> <articles> <item> <title><![cdata[%s]]></title> <description><![cdata[s]]></description> <picurl><![cdata[url]]></picurl> <url><![cdata[url]]></url> </item> <item> <title><![cdata[%s]]></title> <description><![cdata[s]]></description> <picurl><![cdata[url]]></picurl> <url><![cdata[url]]></url> </item> <item> <title><![cdata[%s]]></title> <description><![cdata[s]]></description> <picurl><![cdata[url]]></picurl> <url><![cdata[url]]></url> </item> </articles> <funcflag>1</funcflag> </xml>"; $url="http://222.206.65.12/opac/arch_rss.php?dept=all&title={$keyword}&doctype=all&lang_code=all&match_flag=forward&displaypg=20&showmode=list&orderby=desc&sort=cata_date&onlylendable=no"; 高考历年真题 $fa=file_get_contents($url); $f=simplexml_load_string($fa); $da1=$f->channel->item[0]->title; $da2=$f->channel->item[1]->title; $da3=$f->channel->item[2]->title; $resultstr = sprintf($texttpl, $fromurname, $tourname, $time,$da1,$da2,$da3); echo $resultstr; }el { echo ""; exit; } } private function checksignature() { $signature = $_get["signature"]; $timestamp = $_get["timestamp"]; $nonce = $_get["nonce"]; $token = token; $tmparr = array($token, $timestamp, $nonce); sort($tmparr); $tmpstr = implode( $tmparr ); $tmpstr = sha1( $tmpstr ); if( $tmpstr == $signature ){ return true; }el{ return 一千米多少公里fal; } }}?>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持www.887551.com。
本文发布于:2023-04-06 16:58:54,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/a41368f2eab5f218bd855de9c2fca7c8.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php微信公众号开发之校园图书馆.doc
本文 PDF 下载地址:php微信公众号开发之校园图书馆.pdf
留言与评论(共有 0 条评论) |