PHP code example of hejunjie / wechat-bill-parser

1. Go to this page and download the library: Download hejunjie/wechat-bill-parser 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/ */

    

hejunjie / wechat-bill-parser example snippets


use Hejunjie\WechatBillParser\WechatBillParser;
use Hejunjie\WechatBillParser\ParseOptions;

$zipFile = '/path/to/微信支付账单.zip';

$options = new ParseOptions($zipFile);
$options->onPasswordFound = function ($password) {
    echo "password:$password\n";
    return true; // Returning false will terminate the subsequent parsing process.
};
$options->onDataParsed = function ($data) {
    echo "name " . $data['real_name'] . PHP_EOL;
    echo "account " . $data['account'] . PHP_EOL;
    echo "A total of " . count($data['data']) . " records have been parsed.\n";
    return true; // Returning false will skip the HTML generation step (under development).
};

// tips: Future versions may support directly generating a bill report as an HTML file.

$parser = new WechatBillParser();
$parser->parse($options);

[
  'real_name' => '张三', // name
  'account' => '18273727771', // WeChat Nickname
  'data' => [
      // Each line of bill record
      ["Transaction Time", "Transaction Type", "Counterparty", "Product", "Income/Expense", "Amount (CNY)", "Payment Method", "Current Status", "Transaction ID", "Merchant Order ID", "Remarks"]
      ...
  ]
]