婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > php微信公眾號開發之校園圖書館

php微信公眾號開發之校園圖書館

熱門標簽:兼職做地圖標注好賺錢嗎 400 電話 辦理 亳州企業外呼系統 山東電銷卡外呼系統原理是什么 海南外呼系統方案 蘇州外呼系統有效果嗎 智能電銷語音機器人資訊 打開百度地圖標注 地圖標注怎么做商戶驗證

本文實例為大家分享了php微信公眾號圖書館的具體代碼,供大家參考,具體內容如下

圖書來源:山東理工大學圖書館書目檢索系統

搜索書名返回是xml格式數據:

核心代碼如下:

$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
  $fromUsername = $postObj->FromUserName;
  $toUsername = $postObj->ToUserName;
  $keyword = trim($postObj->Content);
  $time = time();
  $textTpl = "xml>
     ToUserName>![CDATA[%s]]>/ToUserName>
     FromUserName>![CDATA[%s]]>/FromUserName>
     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/search_rss.php?dept=ALLtitle={$keyword}doctype=ALLlang_code=ALLmatch_flag=forwarddisplaypg=20showmode=listorderby=DESCsort=CATA_DATEonlylendable=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, $fromUsername, $toUsername, $time,$da1,$da2,$da3);
echo $resultStr;

index.php整體代碼如下:

?php
/**
 * wechat php test
 */

//define your token
define("TOKEN", "weixin");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->responseMsg();

class wechatCallbackapiTest
{
 public function valid()
 {
  $echoStr = $_GET["echostr"];

  //valid signature , option
  if($this->checkSignature()){
   echo $echoStr;
   exit;
  }
 }

 public function responseMsg()
 {
  //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, 'SimpleXMLElement', LIBXML_NOCDATA);
    $fromUsername = $postObj->FromUserName;
    $toUsername = $postObj->ToUserName;
    $keyword = trim($postObj->Content);
    $time = time();
    $textTpl = "xml>
       ToUserName>![CDATA[%s]]>/ToUserName>
       FromUserName>![CDATA[%s]]>/FromUserName>
       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/search_rss.php?dept=ALLtitle={$keyword}doctype=ALLlang_code=ALLmatch_flag=forwarddisplaypg=20showmode=listorderby=DESCsort=CATA_DATEonlylendable=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, $fromUsername, $toUsername, $time,$da1,$da2,$da3);
     echo $resultStr;


  }else {
   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;
  }else{
   return false;
  }
 }
}

?>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • php微信公眾號開發模式詳解
  • PHP實現微信公眾號驗證Token的示例代碼
  • php實現微信公眾號創建自定義菜單功能的實例代碼
  • PHP實現的微信公眾號掃碼模擬登錄功能示例
  • 微信公眾平臺開發教程③ PHP實現微信公眾號支付功能圖文詳解
  • php微信公眾號開發之快遞查詢
  • php微信公眾號開發之歡迎老朋友
  • php微信公眾號開發之關鍵詞回復
  • php微信公眾號開發之圖片回復
  • 基于PHP的微信公眾號的開發流程詳解

標簽:安康 溫州 清遠 綏化 紹興 呼倫貝爾 金華 萊蕪

巨人網絡通訊聲明:本文標題《php微信公眾號開發之校園圖書館》,本文關鍵詞  php,微信,公眾,號開,發之,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《php微信公眾號開發之校園圖書館》相關的同類信息!
  • 本頁收集關于php微信公眾號開發之校園圖書館的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 沁水县| 乌苏市| 交口县| 衡南县| 尼玛县| 永胜县| 朝阳区| 湟源县| 陇西县| 荆门市| 巴青县| 普宁市| 蓬溪县| 屏边| 绥中县| 清水河县| 安岳县| 西林县| 虎林市| 繁昌县| 阜新市| 渭源县| 石台县| 阿拉善左旗| 彭山县| 开封县| 丹阳市| 冷水江市| 克山县| 定结县| 深水埗区| 新民市| 和林格尔县| 梓潼县| 大埔区| 宽甸| 贞丰县| 梓潼县| 潍坊市| 山东| 阿拉尔市|