Home  >  Article  >  Backend Development  >  微信公众平台自定义菜单及高级接口PHP SDK_PHP教程

微信公众平台自定义菜单及高级接口PHP SDK_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:31:301209browse

本文介绍介绍微信公众平台自定义菜单及高级接口的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. 使用微信扫描下面的二维码

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/763567.htmlTechArticle本文介绍介绍微信公众平台自定义菜单及高级接口的PHP SDK及使用方法。 作者 方倍工作室 修正记录: 2014.05.03 v1.0 SDK 源码: = "" = "" __cons...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn