本文介紹介紹公眾平台自訂菜單及進階介面的PHP SDK及使用方法。
作者
方倍工作室
修正記錄:
2014.05.03 v1.0
SDK 源碼:
= "" = "" __construct( = , = ( ->appid = ( ->appsecret = ->lasttime = 1395049256 ->access_token = "nRZvVpDU7LxcSi7GnG2LrUcmKbAECzRf0NyDBwKlng4nMPf88d34pkzdNcvhqm4clidLGAS18cN1RTSK60p49zIZY4aO13sF-eqsCs0xjlbad-lKVskk8T7gALQ5dIrgXbQQ_TAesSasjJ210vIqTQ" (() > (->lasttime + 7200 = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".->appid."&secret=".-> = ->https_request( = json_decode(, ->access_token = ["access_token" ->lasttime = get_user_list( = = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=".->access_token."&next_openid=". = ->https_request( json_decode(, get_user_info( = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=".->access_token."&openid=".."&lang=zh_CN" = ->https_request( json_decode(, create_menu( = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".-> = ->https_request(, json_decode(, send_custom_message(, , = ('touser' => ( 'text': ['msgtype'] = 'text' ['text'] = ('content'=> ( = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=".-> ->https_request(, (json_encode( create_qrcode(, ( 'QR_LIMIT_SCENE': = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": '..'}}}' 'QR_SCENE': = '{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": '..'}}}' = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".-> = ->https_request(, = json_decode(, "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".(["ticket" create_group( = '{"group": {"name": "'..'"}}' = "https://api.weixin.qq.com/cgi-bin/groups/create?access_token=".-> = ->https_request(, json_decode(, update_group(, = '{"openid":"'..'","to_groupid":'..'}' = "https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=".-> = ->https_request(, json_decode(, upload_media(, = ("media" => "@".().'\\'. = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=".->access_token."&type=". = ->https_request(, json_decode(, https_request(, = = curl_setopt(, CURLOPT_URL, curl_setopt(, CURLOPT_SSL_VERIFYPEER, curl_setopt(, CURLOPT_SSL_VERIFYHOST, (!( curl_setopt(, CURLOPT_POST, 1 curl_setopt(, CURLOPT_POSTFIELDS, curl_setopt(, CURLOPT_RETURNTRANSFER, 1 = curl_exec( curl_close( }
調用方法:
初始化對象
= class_weixin_adv("wx6222221b11111111", "3079cb22ad383ae7371d12aed1b2d0cc");
查看Access Token
(->access_token);
建立二維碼
(->create_qrcode("QR_SCENE", "134324234"));
擷取粉絲列表
(->get_user_list());
擷取使用者資訊
= "oLVPpjkttuZTbwDwN7vjHNlqsmPs"(->get_user_info());
建立菜單
='{"button":[{"name":"方倍工作室","sub_button":[{"type":"click","name":"公司簡介","key":"公司簡介"},{"type":"click","name":"社會責任","key":"社會責任"},{"type":"click","name":"聯絡我們","key":"聯絡我們"}]},{"name":"產品服務","sub_button":[{"type":"click","name":"平台","key":"平台"},{"type":"click","name":"微博應用","key":"微博應用"},{"type":"click","name":"手機網站","key":"手機網站"}]},{"name":"支援人員","sub_button":[{"type":"click","name":"文檔下載","key":"文檔下載"},{"type":"click","name":"技術社區","key":"技術社區"},{"type":"click","name":"服務熱線","key":"服務熱線"}]}]}'(->create_menu());
使用者分組
(->create_group("老師"(->update_group(, "100"));
上傳下載多媒體
(->upload_media("image","pondbay.jpg"));
發送客服訊息
(->send_custom_message(, "text", "asdf"));
=========================================================
方倍工作室公眾平台帳號關注方法:
1. 通訊錄-添加朋友-尋找公眾號-搜尋“方倍工作室”
2. 通訊錄-添加朋友-搜號碼-輸入“pondbaystudio”
3. 使用掃描下面的二維碼
http://www.bkjia.com/PHPjc/763567.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/763567.htmlTechArticle本文介紹介紹公眾平台自訂菜單及進階介面的PHP SDK及使用方法。 作者 方倍工作室 修正記錄: 2014.05.03 v1.0 SDK 源碼: = "" = "" __cons...