quansitech/easy-get-flower

txgy xhh easygetflower

Installs: 497

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/quansitech/easy-get-flower

v1.2.0 2025-10-14 03:23 UTC

This package is auto-updated.

Last update: 2025-10-14 03:23:56 UTC


README

腾讯公益小红花API

安装

composer require quansitech/easy-get-flower

实例化类

// 参数说明
// array $config 腾讯公益小红花相关配置项
$config = [
    'appid' => 'xxx',
    'key' => 'xxx',
    'et' => 'xxx',
];
$get_flower = new \EasyGetFlower\Application($config);

getUserXhhNum

查询用户累计获取小红花数量
// 参数说明
// $openid 用户微信openid
$openid = 'xxx';
$get_flower->getUserXhhNum($openid);

// 返回值说明
// 返回用户累计小红花数量

hasBillUsed

判断业务订单是否已使用
// 参数说明
// $openid 用户微信openid
// $trans_code 业务订单号,需要以YYYYMMDD开头,不能超过32位
$openid = 'xxx';
$trans_code = date('Ymd').'1';
$get_flower->hasBillUsed($openid,$trans_code);

// 返回值说明
// 0 未使用
// 1 已使用

buildLink

生成领花页链接
// 参数说明
// $openid 用户微信openid
// $trans_code 业务订单号,需要以YYYYMMDD开头,不能超过32位
// $xhh_num 期望派发的小红花数量
// $time_expire 订单重试结束时间,格式为YYYY-MM-DD HH:mm:SS,不能超过10分钟,若为空则是当前时间加10分钟
// jump_type 跳转类型,目前支持H5和MP小程序,默认为H5
// wechat_status 设置微信状态,0 否 1 是,默认为 0
// pre_try_param 预发花接口额外参数,默认为空

$openid = 'xxx';
$trans_code = date('Ymd').'1';
$xhh_num = '1';
$time_expire = '';
$jump_type = 'H5';
$wechat_status = 0;
$pre_try_param = [
    'business_info' => [
        'key1' => 10,
        'key2' => 1
    ],
    'attach' => 'attach'
];

$get_flower->buildLink($openid,$trans_code,$xhh_num,$time_expire,$jump_type,$wechat_status,$pre_try_param);

// 返回值说明
// link 领花页链接
// exchange_id 业务的预发花id

buildSilenceWechatStatusLink

生成无感发花设置微信状态路径
$get_flower->buildSilenceWechatStatusLink();

// 返回值说明
// link 无感发花设置微信状态路径

返回错误统一说明

// 若接口返回false,说明是正常的业务错误
// 获取具体错误
$get_flower->getError();

// 其它非业务错误直接抛出异常