PHP code example of linyuee / wechat

1. Go to this page and download the library: Download linyuee/wechat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

linyuee / wechat example snippets


$data = $wechat->getUserinfoByCode($code);
angular2html
$res = $wechat->user()->getUserInfo('ogzUjwMevWmSnr__y9aOMVCVvU1g');
angular2html
$res = $wechat->user()->getAllOpenid('ogzUjwMevWmSnr__y9aOMVCVvU1g');

$wechat = new \Linyuee\Wechat('appid','secret',$cacheDriver)
$data = $wechat->getQrcode('id'); //id是带的参数

$response = new \Linyuee\WechatResponse('your_token');
$response->setWelcomeReply('欢迎关注')->run();

$response = new WechatResponse('chebao');
        $auto_rule = array(       //可以是数组也可以是字符串,如果是字符串的话不管发什么都会回复该字符串
            '你好'=>'很高兴认识你',
            '我要福利'=>'暂时没有福利',
            'test'=>'测试'
        );
$response->setWelcomeReply('欢迎关注')->setAutoReply($auto_rule)->run();

$wechat = new PayClient('appid','mch_id','key'); //初始化
$input1 = array(  //公众号支付参数
            //必须参数
            'mch_id'=>'1900009851',
            'body'=>'腾讯充值中心-QQ会员充值', 
            'out_trade_no'=>random_int(100000,99999999),
            'total_fee'=>10,
            'notify_url'=>'$notify_url',
            'openid'=>'23da2Ar3efD23r1rd12S',//发起支付用户的openid
            //非必须参数
            'device_info'=>'',
            'attach'=>'', //附加数据,回调时会返回
            'time_start'=>'20091225091010',
            'time_expire'=>'20091227091010',
            'detail'=>'',
            'goods_tag'=>'',
            'scene_info'=>''
        );
        $input2 = array(   //app支付参数
            //必须参数
            'mch_id'=>'1900009851',
            'body'=>'腾讯充值中心-QQ会员充值',
            'out_trade_no'=>random_int(100000,99999999),
            'total_fee'=>10,
            'notify_url'=>'$notify_url',
            //非必须参数
            'device_info'=>'',
            'attach'=>'', //附加数据,回调时会返回
            'time_start'=>'20091225091010',
            'time_expire'=>'20091227091010',
            'detail'=>'',
            'goods_tag'=>'',
            'scene_info'=>''
        );

$res = $wechat->unifiedOrder($input1)->jsapiPay();
$res = $wechat->unifiedOrder($input2)->appPay();
$res = $wechat->unifiedOrder($input2)->webPay();


$data = array(
       'total_fee'=>'订单金额',
       'out_refund_no'=>'自定义退款号',
       'refund_fee'=>'退款金额'
      );
$res = $pay->refund($data)->setCert(array(
        'SSLCERT_PATH'=>'/etc/Cert/wechat/apiclient_cert.pem',
        'SSLKEY_PATH'=>'/etc/Cert/wechat/apiclient_key.pem'
      ))->refundByOutTradeNo($params['out_trade_no']);