PHP Class callmez\wechat\sdk\Wechat

Inheritance: extends yii\base\Component
Show file Open project: callmez/yii2-wechat-sdk

Public Properties

Property Type Description
$appId 公众号appId
$appSecret 公众号appSecret
$cachePrefix string 数据缓存前缀
$cacheTime integer 数据缓存时长
$errorCode array 回调错误代码 可用于检索用户返回错误详情
$lastErrorInfo 最后请求的错误信息
$operCode array 操作ID(会化状态)定义 可用于显示客服聊天记录的操作详情
$partnerId 财付通商户身份标识。
$partnerKey 财付通商户权限密钥 Key
$paySignKey 公众号支付请求中用于加密的密钥 Key,可验证商户唯一身份,PaySignKey 对应于支付场景中的 appKey 值。
$token 公众号接口验证token,可由您来设定. 并填写在微信公众平台->开发者中心

Protected Properties

Property Type Description
$_accessToken
$_jsApiTicket

Public Methods

Method Description
activateMemberCard ( array $requestParams = [] ) : boolean 激活/绑定会员卡
addDeliveryTemplate ( array $deliveryTemplate ) : integer | boolean 增加邮费模板
addPoi ( array $requestParams = [] ) : boolean 创建门店
addProductStock ( $productId, $quantity, array $skuInfo = null ) : boolean 增加库存
addShelf ( array $data ) : boolean 增加货架
addShopGroup ( string $groupName, array $productIdList ) : boolean 增加店铺分组
cancelSendArticles ( $messageId ) 取消群发消息
cardConsume ( $code, null $cardId = null ) : array | boolean 消费(核销)卡券
checkOauth2AccessToken ( $accessToken, $openId ) : boolean 检验授权凭证(access_token)是否有效
checkSignature ( string $signature = null, string $timestamp = null, string $nonce = null ) : boolean 微信服务器请求签名检测
closeOrder ( integer $orderId ) : boolean 关闭订单
createCard ( array $requestParams = [] ) : array | boolean 创建卡券
createCardQrcode ( array $requestParams = [] ) : boolean | string 创建卡券二维码
createGroup ( $name ) : array | boolean 创建分组
createMenu ( array $buttons ) : boolean 创建菜单
createProduct ( array $data ) : array | boolean 添加商品
createQrCode ( array $params ) : array | boolean 创建QR二维码 调用的参数示例 $params = [ 二维码类型,QR_SCENE为临时,QR_LIMIT_SCENE为永久,QR_LIMIT_STR_SCENE为永久的字符串参数值,默认为QR_SCENE 'action_name' => 'QR_SCENE', 'action_info' => [ 'scene' => [ 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000) 'scene_id' => $sceneId, 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64,仅永久二维码支持此字段 'scene_str' => $sceneStr ] ] ];
createShortUrl ( $longUrl ) : boolean 创建短链接
deleteCard ( $card_id ) : boolean 删除卡券
deleteDeliverTemplate ( integer $templateId ) : boolean 删除邮费模板
deleteMenu ( ) : boolean 删除菜单
deletePoi ( $poi_id ) : boolean 删除门店
deleteProduct ( $productId ) : boolean 删除商品
deleteShelf ( $shelfId ) : boolean 删除货架
deleteShopGroup ( integer $groupId ) : boolean 删除店铺分组
getAccessToken ( boolean $force = false ) : string 获取AccessToken 会自动判断超时时间然后重新获取新的token (会智能缓存accessToken)
getBatchCards ( integer $offset, integer $count = 50 ) : boolean 得到批量查询的卡券(获取卡券列表)
getCard ( $card_id ) : boolean 得到单个卡券详情
getCardColors ( ) : boolean 获取卡券颜色列表
getCategoryProperty ( $cateId ) : array | boolean 获取指定分类的所有属性
getCategorySkuList ( $cateId ) : array | boolean 获取指定分类的单品
getCategorySubCategory ( $cateId ) : array | boolean 获取指定分类的子分类
getCode ( $code, null $card_id = null ) : array | boolean 得到Code信息
getCustomerServiceRecords ( string $openId, integer $startTime, integer $endTime, integer $pageIndex = 1, integer $pageSize = 1000 ) : array | boolean 获取关注者的客服聊天记录
getDecryptCode ( $encrypt_code ) : boolean 获取解码后的Code
getDeliverTemplate ( integer $templateId ) : array | boolean 获取指定ID的邮费模板
getDeliverTemplateList ( ) : array | boolean 获取所有邮费模板
getGroupId ( $openId ) : array | boolean 根据关注者openID获取分组ID
getGroupList ( ) : array | boolean 获取分组列表
getJsApiTicket ( boolean $force = false ) : mixed 获取jsapi_ticket 会自动判断超时时间然后重新获取新的ticket (会智能缓存jsApiTicket)
getMedia ( $mediaId ) : array | boolean 下载媒体文件
getMemberInfo ( $openId, string $lang = 'zh_CN' ) : array | boolean 获取关注者基本信息
getMemberList ( string $nextOpenId = null ) : array | boolean 获取关注者列表
getMenuList ( ) : boolean 获取菜单列表
getOauth2AccessToken ( $code, string $grantType = 'authorization_code' ) : array 网页授权获取用户信息:第二步 通过跳转到getOauth2AuthorizeUrl返回的授权code获取用户资料 (该函数和getAccessToken函数作用不同.请参考文档)
getOauth2AuthorizeUrl ( $redirectUrl, string $state = 'authorize', string $scope = 'snsapi_base' ) : string 网页授权获取用户信息:第一步 通过此函数生成授权url
getOrder ( $orderId ) : boolean 根据订单ID获取订单详情
getOrderByFilter ( array $condition ) : boolean 根据订单状态/创建时间获取订单详情
getPoi ( $poi_id ) : boolean 查询门店
getPoiList ( integer $begin, integer $limit = 20 ) : boolean 查询门店列表
getProduct ( $productId ) : array | boolean 获取商品信息
getProductByStatus ( $status ) : array | boolean 获取指定状态的商品
getQrCodeUrl ( $ticket ) : string 获取二维码图片
getShelf ( $shelfId ) : array | boolean 根据货架ID获取货架信息
getShelfList ( ) : array | boolean 获取所有货架
getShopGroup ( integer $groupId ) : array | boolean 根据分组ID获取分组信息
getShopGroupList ( ) : array | boolean 获取所有分组
getSnsMemberInfo ( $openId, string $oauth2AccessToken, string $lang = 'zh_CN' ) : array | boolean 如果网页授权作用域为snsapi_userinfo,则此时开发者可以通过网页授权后的access_token和openid拉取用户信息了。
httpGet ( $url, null $params = null ) : array Get方式调用微信接口
httpPost ( $url, null $params = null ) : array Post方式调用微信接口
httpRaw ( $url, null $params = null ) : array Post方式发送raw包调用微信接口
init ( )
jsApiConfig ( array $config = [], boolean $debug = YII_DEBUG ) : array 生成js 必要的config 只需在视图文件输出JS代码: wx.config(jsApiConfig()) ?>); // 默认全权限 wx.config(jsApiConfig([ // 只允许使用分享到朋友圈功能 'jsApiList' => [ 'onMenuShareTimeline' ] ])) ?>);
modifyCardStock ( $card_id, integer $increase_stock_value, integer $reduce_stock_value ) : boolean 修改卡券的库存
parseRequestData ( srting $xml = null ) : array 解析微信服务器请求的xml数据
reduceProductStock ( $productId, $quantity, array $skuInfo = null ) : boolean 减少库存
refreshOauth2AccessToken ( $refreshToken, string $grantType = 'refresh_token' ) : array | boolean 网页授权获取用户信息:第三步(非必须) 由于access_token拥有较短的有效期,当access_token超时后,可以使用refresh_token进行刷新,refresh_token拥有较长的有效期(7天、30天、60天、90天),当refresh_token失效的后,需要用户重新授权。
sendArticles ( array $target, $content, string $type ) : array | boolean 群发消息
sendImage ( string $openId, string $mediaId ) : boolean 发送图片客服消息
sendMusic ( $openId, $thumbMediaId, $musicUrl, $hqMusicUrl, null $title = null, null $description = null ) : boolean 发送音乐客服消息
sendNews ( $openId, array $articles ) : boolean 发送图文客服消息
sendTemplateMessage ( $toUser, $templateId, array $data ) : integer | boolean 发送模板消息给关注者 示例数据 [ "touser" => "接收消息的用户openid", "template_id" => "模板id", "url" => "http://weixin.qq.com/download", "topcolor" => "#FF0000", "data" => [ "first" => [ "value" => "恭喜你购买成功!", "color" => "#173177" ], "product" => [ "value" => "巧克力", "color" => "#173177" ], "price" => [ "value" => "39.8元", "color" => "#173177" ], "time" => [ "value" => "2014年9月16日", "color" => "#173177" ], "remark" => [ "value" => "欢迎再次购买!", "color" => "#173177" ] ]
sendText ( $openId, $content ) : boolean 发送文本客服信息
sendVideo ( string $openId, string $mediaId, string $thumbMediaId, string $title = null, string $description = null ) : boolean 发送视频客服信息
sendVoice ( string $openId, string $mediaId ) : boolean 发送声音客服消息
setAccessToken ( array $data ) 设置AccessToken
setCodeUnavailable ( $code, null $card_id = null ) : boolean 设置卡券为失效
setJsApiTicket ( array $data ) 设置jsapi_ticket
setOrderDelivery ( $orderId, $deliveryCompany, $deliveryTrackNo ) : boolean 设置订单发货信息
updateCard ( $requestParams ) : array | boolean 更新卡券信息
updateCode ( $code, $card_id, $new_code ) : boolean 更新Code 为确保转赠后的安全性,微信允许自定义code的商户对已下发的code进行更改。 注:为避免用户疑惑,建议仅在发生转赠行为后(发生转赠后,微信会通过事件推送的方式告知商户被转赠的卡券code)对用户的code进行更改。
updateDeliverTemplate ( integer $templateId, array $deliveryTemplate ) : boolean 修改邮费模板
updateFeedback ( $openId, $feedbackId ) : boolean 标记客户的投诉处理状态
updateGroupName ( $id, $name ) : boolean 根据分组ID修改分组名
updateMemberGroup ( $openId, $toGroupId ) : boolean 修改关注者所在分组
updateMemberRemark ( $openId, $remark ) : boolean 修改关注者备注
updatePoi ( $requestParams ) : boolean
updateProduct ( $productId, array $data ) : boolean
updateProductStatus ( $productId, $status ) : boolean 更改商品状态(上下架)
updateShelf ( $shelfId, $data ) : boolean 修改货架
updateShopGroup ( $groupId, $groupName ) : boolean 修改分组属性
updateShopGroupProduct ( $groupId, array $productList ) : boolean 修改分组商品
updateUser ( array $requestParams = [] ) : array | boolean 更新用户信息
uploadArticles ( array $articles ) : array | boolean 图文消息上传(高级群发接口)
uploadMedia ( $filePath, $mediaType ) : array | boolean 上传媒体文件
uploadShopImage ( $filePath, null $fileName = null ) : boolean 上传图片(小店接口)
uploadStoreLogo ( $filePath ) : boolean 上传门店LOGO 门店不同于(微店)门店是线下消费场所
uploadVideo ( $mediaId, $title, $description ) : array | boolean 上传多媒体文件(群发接口) 推送消息时 video信息需另外发送一次.

Protected Methods

Method Description
getCache ( $name, null $defaultValue = null ) : mixed 获取微信缓存数据
getCacheKey ( $name ) : string 获取缓存的键值
http ( $url, $params = null, string $type = 'get' ) : boolean | mixed Http协议调用微信接口方法
parseHttpResult ( $url, $params, $method, boolean $force = true ) : boolean | mixed 解析api回调请求 会根据返回结果处理响应的回调结果.如 40001 access_token失效(会强制更新access_token后)重发, 保证请求的的有效
requestAccessToken ( string $grantType = 'client_credential' ) : array 请求服务器access_token
requestJsApiTicket ( string $type = 'jsapi' ) : array 请求服务器jsapi_ticket
sendCustomMessage ( array $data ) : boolean 发送客服消息
setCache ( $name, $value, null $duration = null ) : boolean 缓存微信数据

Method Details

activateMemberCard() public method

激活/绑定会员卡
public activateMemberCard ( array $requestParams = [] ) : boolean
$requestParams array $requestParams = [ "init_bonus" => 100, 初始积分不填为0 "init_balance" => 200, 初始余额不填为0 "bonus_url" => 'www.xxxx.com', 积分查询 "balance_url" => 'www.xxxx.com', 余额查询 "membership_number" => "AAA00000001", 会员卡编号 "code" => "12312313", 创建会员时获得的Code "card_id" => "xxxx_card_id" 卡券id ]
return boolean

addDeliveryTemplate() public method

增加邮费模板
public addDeliveryTemplate ( array $deliveryTemplate ) : integer | boolean
$deliveryTemplate array
return integer | boolean

addPoi() public method

创建门店
public addPoi ( array $requestParams = [] ) : boolean
$requestParams array $requestParams = [ 'business' => [ 'base_info' => [ 'sid' => '33788392', 商户自己的门店ID, 'business_name' => '麦当劳', 门店名称 'branch_name' => '艺苑路店', 分店名称 'province' => '广东省',门店所在省份 'city' => '广州市', 门店所在城市 'district' => '天河区', 门店所在地区 'address' => '天河北路xx号', 门店详细街道地址 'telephone' => '020-12008888', 门店电话 'categories' => ["美食", "快餐", "小吃"], 门店类型 'offset_type' => 1,坐标类型 'longitude' => '115.32375',门店所在地理位置经度 'latitude' => '25.097486', 门店所在地理位置纬度 'photo_list' => [ ['photo_url' => 'www.xx.com'], ['photo_url' => 'www.xx.com'] ] 'recommend' => '麦辣鸡腿堡套餐,麦乐鸡,全家桶', 推荐品 'special' => '免费 wifi,外卖服务', 特色服务 'introduction' => '麦当劳是全球大型跨国连锁餐厅...', 商户简介 'open_time' => '8:00-20:00', 营业时间 'avg_price' => 35, 人均消费 ] ] ]
return boolean

addProductStock() public method

增加库存
public addProductStock ( $productId, $quantity, array $skuInfo = null ) : boolean
$productId 商品ID
$quantity 增加的库存数量
$skuInfo array sku信息,格式"id1:vid1;id2:vid2",如商品为统一规格,则此处赋值为空字符串即可
return boolean

addShelf() public method

增加货架
public addShelf ( array $data ) : boolean
$data array
return boolean

addShopGroup() public method

增加店铺分组
public addShopGroup ( string $groupName, array $productIdList ) : boolean
$groupName string 分组名称
$productIdList array 商品ID集合
return boolean

cancelSendArticles() public method

取消群发消息
public cancelSendArticles ( $messageId )
$messageId 消息ID

cardConsume() public method

消费(核销)卡券
public cardConsume ( $code, null $cardId = null ) : array | boolean
$code
$cardId null
return array | boolean

checkOauth2AccessToken() public method

检验授权凭证(access_token)是否有效
public checkOauth2AccessToken ( $accessToken, $openId ) : boolean
$accessToken
$openId
return boolean

checkSignature() public method

微信服务器请求签名检测
public checkSignature ( string $signature = null, string $timestamp = null, string $nonce = null ) : boolean
$signature string 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
$timestamp string 时间戳
$nonce string 随机数
return boolean

closeOrder() public method

关闭订单
public closeOrder ( integer $orderId ) : boolean
$orderId integer
return boolean

createCard() public method

创建卡券
public createCard ( array $requestParams = [] ) : array | boolean
$requestParams array
return array | boolean

createCardQrcode() public method

创建卡券二维码
public createCardQrcode ( array $requestParams = [] ) : boolean | string
$requestParams array $requestParams = [ 'card_id' => '', (必须) 'code' => '', (当卡券use_custom_code字段为true时必填) 'openid' => '', (当卡券bind_openid字段为true时必填) 'expire_seconds' => 0,(指定二维码有效时间60~1800秒之间,不填默认为永久) 'is_unique_code' => false, (领取是否可再次扫描) 'balance' => 1, (红包余额单位为分) 'outer_id' => 0 (领取场景值) ]
return boolean | string 生成二维码的ticket

createGroup() public method

创建分组
public createGroup ( $name ) : array | boolean
$name 分组名称
return array | boolean

createMenu() public method

创建菜单
public createMenu ( array $buttons ) : boolean
$buttons array 菜单结构字符串 ~~~ $this->createMenu([ [ 'type' => 'click', 'name' => '今日歌曲', 'key' => 'V1001_TODAY_MUSIC' ], [ 'type' => 'view', 'name' => '搜索', 'url' => 'http://www.soso.com' ] ... ]); ~~~
return boolean

createProduct() public method

添加商品
public createProduct ( array $data ) : array | boolean
$data array 商品详细信息 ~~~ $data = [ 'product_base' => [ 'category_id' => [537074298], 'property' => [ [ 'id' => 1075741879, 'vid' => 1079749967 ], [ 'id' => 1075754127, 'vid' => 1079795198 ], [ 'id' => 1075777334, 'vid' => 1079837440 ] ], 'name' => 'testaddproduct', 'sku_info' => [ [ 'id' => 1075741873, 'vid' => [1079742386, 1079742363] ] ], 'main_img' => 'http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ulEKogfsiaua49pvLfUS8Ym0GSYjViaLic0FD3vN0V8PILcibEGb2fPfEOmw/0', 'img' => ['http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ulEKogfsiaua49pvLfUS8Ym0GSYjViaLic0FD3vN0V8PILcibEGb2fPfEOmw/0'], 'detail' => [ [ 'text' => 'test first' ], [ 'img' => 'http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjD3ul1UcLcwxrFdwTKYhH9Q5YZoCfX4Ncx655ZK6ibnlibCCErbKQtReySaVA/0' ], [ 'text' => 'test again' ] ], 'buy_limit' => 10 ], 'sku_list' => [ [ 'sku_id' => '1075741873:1079742386', 'price' => 30, 'icon_url' => 'http://mmbiz.qpic.cn/mmbiz/4whpV1VZl28bJj62XgfHPibY3ORKicN1oJ4CcoIr4BMbfA8LqyyjzOZzqrOGz3f5KWq1QGP3fo6TOTSYD3TBQjuw/0', 'product_code' => 'testing', 'ori_price' => 9000000, 'quantity' => 800 ], [ 'sku_id' => '1075741873:1079742363', 'price' => 30, 'icon_url' => 'http://mmbiz.qpic.cn/mmbiz/4whpV1VZl28bJj62XgfHPibY3ORKicN1oJ4CcoIr4BMbfA8LqyyjzOZzqrOGz3f5KWq1QGP3fo6TOTSYD3TBQjuw/0', 'product_code' => 'testingtesting', 'ori_price' => 9000000, 'quantity' => 800, ] ], 'attrext' => [ 'location' => [ 'country' => '中国', 'province' => '广东省', 'city' => '广州市', 'address' => 'T.I.T创意园', ], 'isPostFree' => 0, 'isHasReceipt' => 1, 'isUnderGuaranty' => 0, 'isSupportReplace' => 0, ], 'delivery_info' => [ 'delivery_type' => 0, 'template_id' => 0, 'express' => [ [ 'id' => 10000027, 'price' => 100, ], [ 'id' => 10000028, 'price' => 100 ], '2' => [ 'id' => 10000029, 'price' => 100 ] ] ] ]; ~~~
return array | boolean

createQrCode() public method

创建QR二维码 调用的参数示例 $params = [ 二维码类型,QR_SCENE为临时,QR_LIMIT_SCENE为永久,QR_LIMIT_STR_SCENE为永久的字符串参数值,默认为QR_SCENE 'action_name' => 'QR_SCENE', 'action_info' => [ 'scene' => [ 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000) 'scene_id' => $sceneId, 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64,仅永久二维码支持此字段 'scene_str' => $sceneStr ] ] ];
public createQrCode ( array $params ) : array | boolean
$params array
return array | boolean

createShortUrl() public method

创建短链接
public createShortUrl ( $longUrl ) : boolean
$longUrl 需要转换的长链接,支持http://、https://、weixin://wxpay 格式的url
return boolean

deleteCard() public method

删除卡券
public deleteCard ( $card_id ) : boolean
$card_id
return boolean

deleteDeliverTemplate() public method

删除邮费模板
public deleteDeliverTemplate ( integer $templateId ) : boolean
$templateId integer 邮费模板ID
return boolean

deleteMenu() public method

删除菜单
public deleteMenu ( ) : boolean
return boolean

deletePoi() public method

删除门店
public deletePoi ( $poi_id ) : boolean
$poi_id
return boolean

deleteProduct() public method

删除商品
public deleteProduct ( $productId ) : boolean
$productId 商品id
return boolean

deleteShelf() public method

删除货架
public deleteShelf ( $shelfId ) : boolean
$shelfId
return boolean

deleteShopGroup() public method

删除店铺分组
public deleteShopGroup ( integer $groupId ) : boolean
$groupId integer
return boolean

getAccessToken() public method

获取AccessToken 会自动判断超时时间然后重新获取新的token (会智能缓存accessToken)
public getAccessToken ( boolean $force = false ) : string
$force boolean 是否强制获取
return string

getBatchCards() public method

得到批量查询的卡券(获取卡券列表)
public getBatchCards ( integer $offset, integer $count = 50 ) : boolean
$offset integer 起始偏移量
$count integer 需要查询的卡片的数量(数量最大 50)
return boolean

getCache() protected method

获取微信缓存数据
protected getCache ( $name, null $defaultValue = null ) : mixed
$name
$defaultValue null
return mixed

getCacheKey() protected method

获取缓存的键值
protected getCacheKey ( $name ) : string
$name
return string

getCard() public method

得到单个卡券详情
public getCard ( $card_id ) : boolean
$card_id
return boolean

getCardColors() public method

获取卡券颜色列表
public getCardColors ( ) : boolean
return boolean

getCategoryProperty() public method

获取指定分类的所有属性
public getCategoryProperty ( $cateId ) : array | boolean
$cateId 分类ID
return array | boolean

getCategorySkuList() public method

获取指定分类的单品
public getCategorySkuList ( $cateId ) : array | boolean
$cateId 分类ID
return array | boolean

getCategorySubCategory() public method

获取指定分类的子分类
public getCategorySubCategory ( $cateId ) : array | boolean
return array | boolean

getCode() public method

得到Code信息
public getCode ( $code, null $card_id = null ) : array | boolean
$code
$card_id null 要消耗序列号所述的 card_id,生成券时 use_custom_code 填写 true 时必填。非自 定义 code 不必填写。
return array | boolean

getCustomerServiceRecords() public method

获取关注者的客服聊天记录
public getCustomerServiceRecords ( string $openId, integer $startTime, integer $endTime, integer $pageIndex = 1, integer $pageSize = 1000 ) : array | boolean
$openId string 关注者的openID
$startTime integer 查询开始时间,UNIX时间戳
$endTime integer 查询结束时间,UNIX时间戳,每次查询不能跨日查询
$pageIndex integer 每页大小,每页最多拉取1000条
$pageSize integer 查询第几页,默认从1开始
return array | boolean

getDecryptCode() public method

获取解码后的Code
public getDecryptCode ( $encrypt_code ) : boolean
$encrypt_code 通过 choose_card_info 获取的加密字符串
return boolean

getDeliverTemplate() public method

获取指定ID的邮费模板
public getDeliverTemplate ( integer $templateId ) : array | boolean
$templateId integer 邮费模板ID
return array | boolean

getDeliverTemplateList() public method

获取所有邮费模板

getGroupId() public method

根据关注者openID获取分组ID
public getGroupId ( $openId ) : array | boolean
$openId 关注者openID
return array | boolean

getGroupList() public method

获取分组列表
public getGroupList ( ) : array | boolean
return array | boolean

getJsApiTicket() public method

获取jsapi_ticket 会自动判断超时时间然后重新获取新的ticket (会智能缓存jsApiTicket)
public getJsApiTicket ( boolean $force = false ) : mixed
$force boolean
return mixed

getMedia() public method

下载媒体文件
public getMedia ( $mediaId ) : array | boolean
$mediaId 媒体文件id
return array | boolean

getMemberInfo() public method

获取关注者基本信息
public getMemberInfo ( $openId, string $lang = 'zh_CN' ) : array | boolean
$openId 关注者openID
$lang string 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语
return array | boolean

getMemberList() public method

获取关注者列表
public getMemberList ( string $nextOpenId = null ) : array | boolean
$nextOpenId string 第一个拉取的OPENID,不填默认从头开始拉取
return array | boolean

getMenuList() public method

获取菜单列表
public getMenuList ( ) : boolean
return boolean

getOauth2AccessToken() public method

网页授权获取用户信息:第二步 通过跳转到getOauth2AuthorizeUrl返回的授权code获取用户资料 (该函数和getAccessToken函数作用不同.请参考文档)
public getOauth2AccessToken ( $code, string $grantType = 'authorization_code' ) : array
$code
$grantType string
return array

getOauth2AuthorizeUrl() public method

网页授权获取用户信息:第一步 通过此函数生成授权url
public getOauth2AuthorizeUrl ( $redirectUrl, string $state = 'authorize', string $scope = 'snsapi_base' ) : string
$redirectUrl 授权后重定向的回调链接地址,请使用urlencode对链接进行处理
$state string 重定向后会带上state参数,开发者可以填写a-zA-Z0-9的参数值
$scope string 应用授权作用域,snsapi_base (不弹出授权页面,直接跳转,只能获取用户openid), snsapi_userinfo (弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息)
return string

getOrder() public method

根据订单ID获取订单详情
public getOrder ( $orderId ) : boolean
$orderId
return boolean

getOrderByFilter() public method

根据订单状态/创建时间获取订单详情
public getOrderByFilter ( array $condition ) : boolean
$condition array ~~~ $condition = [ 'status' => 2, // 订单状态(不带该字段-全部状态, 2-待发货, 3-已发货, 5-已完成, 8-维权中, ) 'begintime' => 1397130460, // 订单创建时间起始时间(不带该字段则不按照时间做筛选) 'endtime' => 1397130470 // 订单创建时间终止时间(不带该字段则不按照时间做筛选) ]; ~~~
return boolean

getPoi() public method

查询门店
public getPoi ( $poi_id ) : boolean
$poi_id
return boolean

getPoiList() public method

查询门店列表
public getPoiList ( integer $begin, integer $limit = 20 ) : boolean
$begin integer
$limit integer
return boolean

getProduct() public method

获取商品信息
public getProduct ( $productId ) : array | boolean
$productId
return array | boolean

getProductByStatus() public method

获取指定状态的商品
public getProductByStatus ( $status ) : array | boolean
$status 商品状态(0-全部, 1-上架, 2-下架)
return array | boolean

getQrCodeUrl() public method

获取二维码图片
public getQrCodeUrl ( $ticket ) : string
$ticket 获取的二维码ticket,凭借此ticket可以在有效时间内换取二维码。
return string

getShelf() public method

根据货架ID获取货架信息
public getShelf ( $shelfId ) : array | boolean
$shelfId
return array | boolean

getShelfList() public method

获取所有货架
public getShelfList ( ) : array | boolean
return array | boolean

getShopGroup() public method

根据分组ID获取分组信息
public getShopGroup ( integer $groupId ) : array | boolean
$groupId integer
return array | boolean

getShopGroupList() public method

获取所有分组
public getShopGroupList ( ) : array | boolean
return array | boolean

getSnsMemberInfo() public method

如果网页授权作用域为snsapi_userinfo,则此时开发者可以通过网页授权后的access_token和openid拉取用户信息了。
public getSnsMemberInfo ( $openId, string $oauth2AccessToken, string $lang = 'zh_CN' ) : array | boolean
$openId
$oauth2AccessToken string
$lang string
return array | boolean

http() protected method

Http协议调用微信接口方法
protected http ( $url, $params = null, string $type = 'get' ) : boolean | mixed
$url api地址
$params 参数
$type string 提交类型
return boolean | mixed

httpGet() public method

Get方式调用微信接口
public httpGet ( $url, null $params = null ) : array
$url
$params null
return array

httpPost() public method

Post方式调用微信接口
public httpPost ( $url, null $params = null ) : array
$url
$params null
return array

httpRaw() public method

Post方式发送raw包调用微信接口
public httpRaw ( $url, null $params = null ) : array
$url
$params null
return array

init() public method

public init ( )

jsApiConfig() public method

生成js 必要的config 只需在视图文件输出JS代码: wx.config(jsApiConfig()) ?>); // 默认全权限 wx.config(jsApiConfig([ // 只允许使用分享到朋友圈功能 'jsApiList' => [ 'onMenuShareTimeline' ] ])) ?>);
public jsApiConfig ( array $config = [], boolean $debug = YII_DEBUG ) : array
$config array
$debug boolean
return array

modifyCardStock() public method

修改卡券的库存
public modifyCardStock ( $card_id, integer $increase_stock_value, integer $reduce_stock_value ) : boolean
$card_id 卡券id
$increase_stock_value integer 增加库存值
$reduce_stock_value integer 减少库存值
return boolean

parseHttpResult() protected method

解析api回调请求 会根据返回结果处理响应的回调结果.如 40001 access_token失效(会强制更新access_token后)重发, 保证请求的的有效
protected parseHttpResult ( $url, $params, $method, boolean $force = true ) : boolean | mixed
$url
$params
$method
$force boolean 是否强制更新access_token 并再次请求
return boolean | mixed

parseRequestData() public method

解析微信服务器请求的xml数据
public parseRequestData ( srting $xml = null ) : array
$xml srting 服务发送的xml数据
return array

reduceProductStock() public method

减少库存
public reduceProductStock ( $productId, $quantity, array $skuInfo = null ) : boolean
$productId 商品ID
$quantity 增加的库存数量
$skuInfo array sku信息,格式"id1:vid1;id2:vid2",如商品为统一规格,则此处赋值为空字符串即可
return boolean

refreshOauth2AccessToken() public method

网页授权获取用户信息:第三步(非必须) 由于access_token拥有较短的有效期,当access_token超时后,可以使用refresh_token进行刷新,refresh_token拥有较长的有效期(7天、30天、60天、90天),当refresh_token失效的后,需要用户重新授权。
public refreshOauth2AccessToken ( $refreshToken, string $grantType = 'refresh_token' ) : array | boolean
$refreshToken
$grantType string
return array | boolean

requestAccessToken() protected method

请求服务器access_token
protected requestAccessToken ( string $grantType = 'client_credential' ) : array
$grantType string
return array

requestJsApiTicket() protected method

请求服务器jsapi_ticket
protected requestJsApiTicket ( string $type = 'jsapi' ) : array
$type string
return array

sendArticles() public method

群发消息
public sendArticles ( array $target, $content, string $type ) : array | boolean
$target array 发送对象 groupid 或 openid ~~~ $target = [ 'filter' => [ 'group_id' => 'groupId', ] ]; //OR $target = [ 'touser' => [ 'openId1', 'openId2', 'openId3', ] ]; ~~~
$content 发送内容 (发送多媒体只需发送media_id)
$type string 发送类型text, mpnews, voice, image, mpvideo(发送给指定群组), video(发送给指定关注者)
return array | boolean

sendCustomMessage() protected method

发送客服消息
protected sendCustomMessage ( array $data ) : boolean
$data array
return boolean

sendImage() public method

发送图片客服消息
public sendImage ( string $openId, string $mediaId ) : boolean
$openId string 关注者openID
$mediaId string 发送的图片的媒体ID
return boolean

sendMusic() public method

发送音乐客服消息
public sendMusic ( $openId, $thumbMediaId, $musicUrl, $hqMusicUrl, null $title = null, null $description = null ) : boolean
$openId 关注者openID
$thumbMediaId 缩略图的媒体ID
$musicUrl 音乐链接
$hqMusicUrl 高品质音乐链接,wifi环境优先使用该链接播放音乐
$title null 音乐标题
$description null 音乐描述
return boolean

sendNews() public method

发送图文客服消息
public sendNews ( $openId, array $articles ) : boolean
$openId 关注者openID
$articles array 图文信息内容部分 ~~~ $articles = [ 'title' => 'Happy Day', 'description' => 'Is Really A Happy Day', 'url' => 'URL', 'picurl' => 'PIC_URL' ] ~~~
return boolean

sendTemplateMessage() public method

]
public sendTemplateMessage ( $toUser, $templateId, array $data ) : integer | boolean
$toUser 关注者openID
$templateId 模板ID(模板需在公众平台模板消息中挑选)
$data array 模板需要的数据
return integer | boolean

sendText() public method

发送文本客服信息
public sendText ( $openId, $content ) : boolean
$openId 关注者openID
$content 文本消息内容
return boolean

sendVideo() public method

发送视频客服信息
public sendVideo ( string $openId, string $mediaId, string $thumbMediaId, string $title = null, string $description = null ) : boolean
$openId string 关注者openID
$mediaId string 发送的视频的媒体ID
$thumbMediaId string 缩略图的媒体ID
$title string 视频消息的标题
$description string 视频消息的描述
return boolean

sendVoice() public method

发送声音客服消息
public sendVoice ( string $openId, string $mediaId ) : boolean
$openId string 关注者openID
$mediaId string 发送的语音的媒体ID
return boolean

setAccessToken() public method

设置AccessToken
public setAccessToken ( array $data )
$data array

setCache() protected method

缓存微信数据
protected setCache ( $name, $value, null $duration = null ) : boolean
$name
$value
$duration null
return boolean

setCodeUnavailable() public method

设置卡券为失效
public setCodeUnavailable ( $code, null $card_id = null ) : boolean
$code
$card_id null
return boolean

setJsApiTicket() public method

设置jsapi_ticket
public setJsApiTicket ( array $data )
$data array

setOrderDelivery() public method

设置订单发货信息
public setOrderDelivery ( $orderId, $deliveryCompany, $deliveryTrackNo ) : boolean
$orderId 订单ID
$deliveryCompany 物流公司ID 邮政EMS Fsearch_code 申通快递 002shentong 中通速递 066zhongtong 圆通速递 056yuantong 天天快递 042tiantian 顺丰速运 003shunfeng 韵达快运 059Yunda 宅急送 064zhaijisong 汇通快运 020huitong 易迅快递 zj001yixun
$deliveryTrackNo 运单ID
return boolean

updateCard() public method

更新卡券信息
public updateCard ( $requestParams ) : array | boolean
$requestParams
return array | boolean

updateCode() public method

更新Code 为确保转赠后的安全性,微信允许自定义code的商户对已下发的code进行更改。 注:为避免用户疑惑,建议仅在发生转赠行为后(发生转赠后,微信会通过事件推送的方式告知商户被转赠的卡券code)对用户的code进行更改。
public updateCode ( $code, $card_id, $new_code ) : boolean
$code
$card_id
$new_code
return boolean

updateDeliverTemplate() public method

修改邮费模板
public updateDeliverTemplate ( integer $templateId, array $deliveryTemplate ) : boolean
$templateId integer 邮费模板ID
$deliveryTemplate array
return boolean

updateFeedback() public method

标记客户的投诉处理状态
public updateFeedback ( $openId, $feedbackId ) : boolean
$openId 关注者openID
$feedbackId 客户投诉对应的单号
return boolean

updateGroupName() public method

根据分组ID修改分组名
public updateGroupName ( $id, $name ) : boolean
$id 分组的ID
$name 修改后的分组名
return boolean

updateMemberGroup() public method

修改关注者所在分组
public updateMemberGroup ( $openId, $toGroupId ) : boolean
$openId 关注者openID
$toGroupId 分组ID
return boolean

updateMemberRemark() public method

修改关注者备注
public updateMemberRemark ( $openId, $remark ) : boolean
$openId 关注者openID
$remark 备注内容
return boolean

updatePoi() public method

public updatePoi ( $requestParams ) : boolean
$requestParams $requestParams = [ 'business' => [ 'base_info' => [ 'poi_id' => '271864249', 商户自己的门店ID, 'telephone' => '020-12008888', 门店电话 'photo_list' => [ ['photo_url' => 'www.xx.com'], ['photo_url' => 'www.xx.com'] ] 'recommend' => '麦辣鸡腿堡套餐,麦乐鸡,全家桶', 推荐品 'special' => '免费 wifi,外卖服务', 特色服务 'introduction' => '麦当劳是全球大型跨国连锁餐厅...', 商户简介 'open_time' => '8:00-20:00', 营业时间 'avg_price' => 35, 人均消费 ] ] ]
return boolean

updateProduct() public method

public updateProduct ( $productId, array $data ) : boolean
$productId
$data array
return boolean

updateProductStatus() public method

更改商品状态(上下架)
public updateProductStatus ( $productId, $status ) : boolean
$productId
$status 商品状态(0-全部, 1-上架, 2-下架)
return boolean

updateShelf() public method

修改货架
public updateShelf ( $shelfId, $data ) : boolean
$shelfId
$data
return boolean

updateShopGroup() public method

修改分组属性
public updateShopGroup ( $groupId, $groupName ) : boolean
$groupId
$groupName
return boolean

updateShopGroupProduct() public method

修改分组商品
public updateShopGroupProduct ( $groupId, array $productList ) : boolean
$groupId
$productList array 分组的商品集合
return boolean

updateUser() public method

更新用户信息
public updateUser ( array $requestParams = [] ) : array | boolean
$requestParams array $requestParams = [ 'code' => '12312313', 要消耗的序列号 'card_id' => 'p1Pj9jr90', 要消耗序列的所属卡券ID 'record_bonus' => '消费30元,获得3积分', 商家自定义积分记录 'add_bonus' => 3, 需要变更的积分 'add_balance' => -3000, 要变更的余额 'record_balance' => '购买焦糖玛琪朵一杯,扣除金额30元' 商家自定义金额记录 ]
return array | boolean

uploadArticles() public method

图文消息上传(高级群发接口)
public uploadArticles ( array $articles ) : array | boolean
$articles array ~~~ $articles = [ [ 'thumb_media_id' => 'qI6_Ze_6PtV7svjolgs-rN6stStuHIjs9_DidOHaj0Q-mwvBelOXCFZiq2OsIU-p', 'author' => 'xxx', 'title' => 'Happy Day', 'content_source_url' => 'www.qq.com', 'content' => 'content', 'digest' => 'digest', 'show_cover_pic' => '1' ] ... ]; ~~~
return array | boolean

uploadMedia() public method

上传媒体文件
public uploadMedia ( $filePath, $mediaType ) : array | boolean
$filePath 媒体文件路径
$mediaType 媒体文件类型, 分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb,主要用于视频与音乐格式的缩略图) 图片(image): 1M,支持JPG格式 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 视频(video):10MB,支持MP4格式 缩略图(thumb):64KB,支持JPG格式
return array | boolean

uploadShopImage() public method

上传图片(小店接口)
public uploadShopImage ( $filePath, null $fileName = null ) : boolean
$filePath 文件完整路径
$fileName null 文件名 如不填写.则使用文件路径里的名称
return boolean

uploadVideo() public method

但是上传还是必须通过 uploadMedia() 上传 获取到mediaId后再通过此函数 提交一次 获得最终的media_id 才可以推送消息
public uploadVideo ( $mediaId, $title, $description ) : array | boolean
$mediaId 媒体id
$title 媒体文件的标题
$description 媒体文件的描述
return array | boolean

Property Details

$_accessToken protected property

protected $_accessToken

$_jsApiTicket protected property

protected $_jsApiTicket

$appId public property

公众号appId
public $appId

$appSecret public property

公众号appSecret
public $appSecret

$cachePrefix public property

数据缓存前缀
public string $cachePrefix
return string

$cacheTime public property

数据缓存时长
public int $cacheTime
return integer

$errorCode public property

回调错误代码 可用于检索用户返回错误详情
public array $errorCode
return array

$lastErrorInfo public property

最后请求的错误信息
public $lastErrorInfo

$operCode public property

操作ID(会化状态)定义 可用于显示客服聊天记录的操作详情
public array $operCode
return array

$partnerId public property

财付通商户身份标识。
public $partnerId

$partnerKey public property

财付通商户权限密钥 Key
public $partnerKey

$paySignKey public property

公众号支付请求中用于加密的密钥 Key,可验证商户唯一身份,PaySignKey 对应于支付场景中的 appKey 值。
public $paySignKey

$token public property

公众号接口验证token,可由您来设定. 并填写在微信公众平台->开发者中心
public $token