<?php
/**
* 微信公众平台PHP-SDK, 官方API部分
* @author dodge <dodgepudding@gmail.com>
* @link https://github.com/dodgepudding/wechat-php-sdk
* @version 1.2
* usage:
* $options = array(
* 'token'=>'tokenaccesskey', //填写你设定的key
* 'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
* 'appid'=>'wxdk1234567890', //填写高级调用功能的app id
* 'appsecret'=>'xxxxxxxxxxxxxxxxxxx' //填写高级调用功能的密钥
* );
* $weObj = new Wechat($options);
* $weObj->valid();
* $type = $weObj->getRev()->getRevType();
* switch($type) {
* case Wechat::MSGTYPE_TEXT:
* $weObj->text("hello, I'm wechat")->reply();
* exit;
* break;
* case Wechat::MSGTYPE_EVENT:
* ....
* break;
* case Wechat::MSGTYPE_IMAGE:
* ...
* break;
* default:
* $weObj->text("help info")->reply();
* }
*
* //获取菜单操作:
* $menu = $weObj->getMenu();
* //设置菜单
* $newmenu = array(
* "button"=>
* array(
* array('type'=>'click','name'=>'最新消息','key'=>'MENU_KEY_NEWS'),
* array('type'=>'view','name'=>'我要搜索','url'=>'http://www.baidu.com'),
* )
* );
* $result = $weObj->createMenu($newmenu);
*/
class Wechat
{
const MSGTYPE_TEXT = 'text';
const MSGTYPE_IMAGE = 'image';
const MSGTYPE_LOCATION = 'location';
const MSGTYPE_LINK = 'link';
const MSGTYPE_EVENT = 'event';
const MSGTYPE_MUSIC = 'music';
const MSGTYPE_NEWS = 'news';
const MSGTYPE_VOICE = 'voice';
const MSGTYPE_VIDEO = 'video';
const MSGTYPE_SHORTVIDEO = 'shortvideo';
const EVENT_SUBSCRIBE = 'subscribe'; //订阅
const EVENT_UNSUBSCRIBE = 'unsubscribe'; //取消订阅
const EVENT_SCAN = 'SCAN'; //扫描带参数二维码
const EVENT_LOCATION = 'LOCATION'; //上报地理位置
const EVENT_MENU_VIEW = 'VIEW'; //菜单 - 点击菜单跳转链接
const EVENT_MENU_CLICK = 'CLICK'; //菜单 - 点击菜单拉取消息
const EVENT_MENU_SCAN_PUSH = 'scancode_push'; //菜单 - 扫码推事件(客户端跳URL)
const EVENT_MENU_SCAN_WAITMSG = 'scancode_waitmsg'; //菜单 - 扫码推事件(客户端不跳URL)
const EVENT_MENU_PIC_SYS = 'pic_sysphoto'; //菜单 - 弹出系统拍照发图
const EVENT_MENU_PIC_PHOTO = 'pic_photo_or_album'; //菜单 - 弹出拍照或者相册发图
const EVENT_MENU_PIC_WEIXIN = 'pic_weixin'; //菜单 - 弹出微信相册发图器
const EVENT_MENU_LOCATION = 'location_select'; //菜单 - 弹出地理位置选择器
const EVENT_SEND_MASS = 'MASSSENDJOBFINISH'; //发送结果 - 高级群发完成
const EVENT_SEND_TEMPLATE = 'TEMPLATESENDJOBFINISH';//发送结果 - 模板消息发送结果
const EVENT_KF_SEESION_CREATE = 'kfcreatesession'; //多客服 - 接入会话
const EVENT_KF_SEESION_CLOSE = 'kfclosesession'; //多客服 - 关闭会话
const EVENT_KF_SEESION_SWITCH = 'kfswitchsession'; //多客服 - 转接会话
const EVENT_CARD_PASS = 'card_pass_check'; //卡券 - 审核通过
const EVENT_CARD_NOTPASS = 'card_not_pass_check'; //卡券 - 审核未通过
const EVENT_CARD_USER_GET = 'user_get_card'; //卡券 - 用户领取卡券
const EVENT_CARD_USER_DEL = 'user_del_card'; //卡券 - 用户删除卡券
const EVENT_MERCHANT_ORDER = 'merchant_order'; //微信小店 - 订单付款通知
const API_URL_PREFIX = 'https://api.weixin.qq.com/cgi-bin';
const AUTH_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//token?grant_type=client_credential&';
const MENU_CREATE_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//menu/create?';
const MENU_GET_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//menu/get?';
const MENU_DELETE_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//menu/delete?';
const MENU_ADDCONDITIONAL_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//menu/addconditional?';
const MENU_DELCONDITIONAL_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//menu/delconditional?';
const MENU_TRYMATCH_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//menu/trymatch?';
const GET_TICKET_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//ticket/getticket?';
const CALLBACKSERVER_GET_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//getcallbackip?';
const QRCODE_CREATE_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//qrcode/create?';
const QR_SCENE = 0;
const QR_LIMIT_SCENE = 1;
const QRCODE_IMG_URL='http://222.178.203.72:19005/whst/63/=lozvdhwhmzppzbnl//cgi-bin/showqrcode?ticket=';
const SHORT_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//shorturl?';
const USER_GET_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//user/get?';
const USER_INFO_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//user/info?';
const USERS_INFO_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//user/info/batchget?';
const USER_UPDATEREMARK_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//user/info/updateremark?';
const GROUP_GET_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//groups/get?';
const USER_GROUP_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//groups/getid?';
const GROUP_CREATE_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//groups/create?';
const GROUP_UPDATE_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//groups/update?';
const GROUP_MEMBER_UPDATE_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//groups/members/update?';
const GROUP_MEMBER_BATCHUPDATE_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//groups/members/batchupdate?';
const CUSTOM_SEND_URL='http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/custom/send?';
const MEDIA_UPLOADNEWS_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//media/uploadnews?';
const MASS_SEND_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/mass/send?';
const TEMPLATE_SET_INDUSTRY_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//template/api_set_industry?';
const TEMPLATE_ADD_TPL_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//template/api_add_template?';
const TEMPLATE_SEND_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/template/send?';
const MASS_SEND_GROUP_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/mass/sendall?';
const MASS_DELETE_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/mass/delete?';
const MASS_PREVIEW_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/mass/preview?';
const MASS_QUERY_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//message/mass/get?';
const UPLOAD_MEDIA_URL = 'http://222.178.203.72:19005/whst/63/_ehkdzZohzvdhwhmzppzbnl//cgi-bin';
const MEDIA_UPLOAD_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//media/upload?';
const MEDIA_UPLOADIMG_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//media/uploadimg?';//图片上传接口
const MEDIA_GET_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//media/get?';
const MEDIA_VIDEO_UPLOAD = '/media/uploadvideo?';
const MEDIA_FOREVER_UPLOAD_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/add_material?';
const MEDIA_FOREVER_NEWS_UPLOAD_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/add_news?';
const MEDIA_FOREVER_NEWS_UPDATE_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/update_news?';
const MEDIA_FOREVER_GET_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/get_material?';
const MEDIA_FOREVER_DEL_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/del_material?';
const MEDIA_FOREVER_COUNT_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/get_materialcount?';
const MEDIA_FOREVER_BATCHGET_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//material/batchget_material?';
const OAUTH_PREFIX = 'https://open.weixin.qq.com/connect/oauth2';
const OAUTH_AUTHORIZE_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//authorize?';
///多客服相关地址
const CUSTOM_SERVICE_GET_RECORD = '/customservice/getrecord?';
const CUSTOM_SERVICE_GET_KFLIST = '/customservice/getkflist?';
const CUSTOM_SERVICE_GET_ONLINEKFLIST = '/customservice/getonlinekflist?';
const API_BASE_URL_PREFIX = 'https://api.weixin.qq.com'; //以下API接口URL需要使用此前缀
const OAUTH_TOKEN_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//sns/oauth2/access_token?';
const OAUTH_REFRESH_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//sns/oauth2/refresh_token?';
const OAUTH_USERINFO_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//sns/userinfo?';
const OAUTH_AUTH_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//sns/auth?';
///多客服相关地址
const CUSTOM_SESSION_CREATE = '/customservice/kfsession/create?';
const CUSTOM_SESSION_CLOSE = '/customservice/kfsession/close?';
const CUSTOM_SESSION_SWITCH = '/customservice/kfsession/switch?';
const CUSTOM_SESSION_GET = '/customservice/kfsession/getsession?';
const CUSTOM_SESSION_GET_LIST = '/customservice/kfsession/getsessionlist?';
const CUSTOM_SESSION_GET_WAIT = '/customservice/kfsession/getwaitcase?';
const CS_KF_ACCOUNT_ADD_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//customservice/kfaccount/add?';
const CS_KF_ACCOUNT_UPDATE_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//customservice/kfaccount/update?';
const CS_KF_ACCOUNT_DEL_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//customservice/kfaccount/del?';
const CS_KF_ACCOUNT_UPLOAD_HEADIMG_URL = 'http://222.178.203.72:19005/whst/63/=cnvmknZczbrcmzmds//customservice/kfaccount/uploadheadimg?';
///卡券相关地址
const CARD_CREATE = '/card/create?';
const CARD_DELETE = '/card/delete?';
const CARD_UPDATE = '/card/update?';
const CARD_GET = '/card/get?';
const CARD_USER_GETCARDLIST = '/card/user