PHP code example of superzc / miniprogram

1. Go to this page and download the library: Download superzc/miniprogram 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/ */

    

superzc / miniprogram example snippets


return [
    'wechat' => [
        'appid' => 'xxx',
        'appsecret' => 'xxx',
    ],
];

use Superzc\Miniprogram\Miniprogram;
use Superzc\Miniprogram\Exceptions\DefaultException as MPDefaultException;

try {
    $miniprogram = new Miniprogram();
    $result = $miniprogram->doSomething();
} catch (MPDefaultException $e) {
    return response()->json([
        'ret' => $e->getCode(),
        'msg' => $e->getMessage(),
    ]);
}

use Superzc\Miniprogram\Facades\Miniprogram;

try {
    $result = Miniprogram::doSomething();
} catch (MPDefaultException $e) {
    return response()->json([
        'ret' => $e->getCode(),
        'msg' => $e->getMessage(),
    ]);
}