微信公眾平台自訂菜單及進階介面PHP SDK_PHP教程

來源:互聯網
上載者:User
本文介紹介紹公眾平台自訂菜單及進階介面的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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.