xcx
Home
其他文档
冯奎博客
GitHub
Home
其他文档
冯奎博客
GitHub
  • 简介
  • 微信
    • 微信
  • QQ
    • QQ
  • 百度
    • 百度
  • 字节跳动
    • 字节跳动
  • 钉钉
    • 钉钉
  • 支付宝
    • 支付宝
method说明参数返回值
openid获取小程序openidstring $codeCollection
userPhone获取用户手机号string $codeCollection
accessToken获取 access_tokenCollection
send微信小程序发送订阅消息...Collection
qrcode获取小程序码或小程序二维码,图片 Buffer...Buffer
check检查内容是否违规...Collection
decrypt检验数据的真实性,并且获取解密后的明文...Collection

完善配置

# 微信小程序配置
$wechatConfig = [
    'appid' => '',
    'secret' => '',
];
$xcx = new \fengkui\Xcx\Wechat($wechatConfig); // 微信

获取小程序openid

$code = ''; // 开放接口,wx.login 获取
$xcx->openid($code);

获取用户手机号

$code = ''; // 使用手机号实时验证组件获取 open-type="getRealtimePhoneNumber" 
$xcx->userPhone($code);

获取 access_token

// 稳定版接口调用凭据
$xcx->accessToken();

微信小程序发送订阅消息

$openid = ''; // 用户openid
$template_id = ''; // 订阅消息模板ID
$data = []; //发送数据
$page = 'pages/index/index'; // 打开页面
$xcx->send($openid, $template_id, $data, $page);

获取小程序码或小程序二维码

$path = '小程序页面路径'; // 小程序页面路径
$type = 2; // 获取类型 1:createwxaqrcode 2(默认):getwxacode 3:getwxacodeunlimit
$env_version = 'release'; // 要打开的小程序版本。正式版为 release(默认) 体验版为 trial 开发版为 develop
$width = 430; // 小程序码宽度 px (默认430)
$is_hyaline=true; // 是否需要透明底色 (默认true)

$xcx->qrcode($path, $type, $env_version, $width,  $is_hyaline);

检查内容是否违规

$content = ''; //内容
$openid = ''; //用户openid
$scene = ''; //场景枚举值(1 资料;2 评论;3 论坛;4 社交日志)
$xcx->check($content, $openid, $scene);

检验数据的真实性,并解密

$sessionKey = ''; // SESSSION KEY
$encryptedData = ''; // 加密的用户数据
$iv = ''; //与用户数据一同返回的初始向量
$xcx->decrypt($sessionKey, $encryptedData, $iv);

同城配送

<?php
require_once('./vendor/autoload.php');

// 完整配置
$config = array(
    'appid'     => 'xxxxxx',
    'secret'    => 'xxxxxx', // 获取access_token时传
    'aes_sn'    => 'xxxxxxxxxxxx',
    'aes_key'   => 'xxxxxxxxxxxx',
    // 'rsa_sn'    => 'xxxxxxxxxxxx',
    'public_key' => './cert/rsa_public_key.txt',
    'private_key' => './cert/rsa_private_key.txt',
    'cert_sn'   => 'xxxxxxxxxxxx',
    'cert_key' => './cert/cert_key.cer',
);

$access_token = '';
$url = 'https://api.weixin.qq.com/cgi-bin/express/intracity/querystore?access_token=' . $access_token;
// access_token可不传,默认扩展包自动获取(注意access_token使用稳定版接口调用获取)
$params = [ // 请求参数
    "wx_store_id" => '4000000000000******',
];
// 查询门店(数据的加密签名验签,扩展包中已处理)
$re = (new \fengkui\Xcx\Wechat($config))->request($url, $params);
Last Updated:
Contributors: kuifeng
Prev
简介
Next
QQ