讀古今文學網 > 微信公眾平台開發:從零基礎到ThinkPHP5高性能框架實踐 > 19.3.3 查詢頁面 >

19.3.3 查詢頁面

查詢已有的頁面,包括在搖一搖頁面出現的主標題、副標題、圖片和點擊進去的超鏈接。微信公眾平台提供兩種查詢方式,可指定頁面ID查詢,也可批量拉取頁面列表。

查詢頁面列表的接口如下。


https:// api.weixin.qq.com/shakearound/page/search?access_token=ACCESS_TOKEN
  

查詢頁面列表可分為以下兩種情況。

1)需要查詢指定頁面時,POST數據示例如下。


{
    "type":1,
    "page_ids":[12345, 23456, 34567]
}
  

圖19-22 編輯頁面

2)需要分頁查詢或者查詢指定範圍內的頁面時,POST數據示例如下。


{
    "type":2,
    "begin":0,
    "count":3
}
  

上述數據的參數說明如表19-13所示。

表19-13 查詢頁面列表接口的參數說明

正確創建時,返回的數據示例如下。


{
    "data":{
        "pages":[
            {
                "comment":"520中國微信會議",
                "description":"2016微信開發",
                "icon_url":"http:// p.qpic.cn/ecc_merchant/0/w_pic_1479985234871/0",
                "page_id":3089022,
                "page_url":"http:// www.doucube.com/wxshake/jumpHongbao.html",
                "title":"微信會議"
            },
            {
                "comment":"自定義鏈接",
                "description":"自定義鏈接",
                "icon_url":"http:// mmbiz.qpic.cn/mmbiz_jpg/BIvw3ibibwAYN3C2Yz4hib6I9o0f
                 RxoMiblflXN06gmZu86jGa0aNtehVlibib6bBzhabiaySxIZaI2Obiab6GyFguRQkA/
                 0?wx_fmt=jpeg",
                "page_id":5374944,
                "page_url":"http:// www.doucube.com/wxshake/AddContact.html",
                "title":"微信搖一搖"
            },
            {
                "comment":"卡券發放100MB流量券",
                "description":"方倍工作室",
                "icon_url":"https:// o2o.gtimg.com/ibeacon/img/coupon-logo.jpg",
                "page_id":585404,
                "page_url":"http:// zb.weixin.qq.com/nearbycgi/html/card/card.html?wechat_
                  card_js=1",
                "title":"卡券發放"
            },
            {
                "comment":"",
                "description":"方倍工作室",
                "icon_url":"https:// o2o.gtimg.com/ibeacon/img/store-logo.png",
                "page_id":5377792,
                "page_url":"https:// zb.weixin.qq.com/app/template/store.html",
                "title":"搖一搖有驚喜"
            },
            {
                "comment":"搖紅包模板測試",
                "description":"吃粽子划龍舟",
                "icon_url":"http:// www.doucube.com/redpacket/120x120.jpg",
                "page_id":3195194,
                "page_url":"http:// zb.weixin.qq.com/app/shakehb/hongbaotpl.html#wechat_
                  redirect",
                "title":"清明節"
            },
            {
                "comment":"系統自動生成",
                "description":"方倍資訊",
                "icon_url":"http:// mmbiz.qpic.cn/mmbiz_png/BIvw3ibibwAYPuibQ37g8KIWj
                 3hGdrH3e97Uj45NRG4Z9cqTiaYT1YgibofmpFPA5CX5SGhDpLZ3180uOI1YWDpTl0
                 Q/0?wx_fmt=png",
                "page_id":5372401,
                "page_url":"https:// zb.weixin.qq.com/app/template/defaultStore.html",
                "title":"發現周邊門店"
            },
            {
                "comment":"",
                "description":"贏取超值優惠",
                "icon_url":"https:// o2o.gtimg.com/ibeacon/img/supermarket_logo.png",
                "page_id":5310884,
                "page_url":"https:// wxo2o.qq.com/ibeacon/beaconweb/html/draw/lottery.
                 html#wechat_redirect",
                "title":"禮從天降"
            }
        ],
        "total_count":7
    },
    "errcode":0,
    "errmsg":"success."
}
  

上述數據的參數說明如表19-14所示。

表19-14 查詢頁面列表接口返回參數說明