PHP code example of yzchan / meituan-union

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

    

yzchan / meituan-union example snippets




use MeituanUnion\Client;
use MeituanUnion\BusinessLine;
use GuzzleHttp\Exception\GuzzleException;
use MeituanUnion\request\OrderListRequest;

$client = new Client('<KEY>', '<SECRET>', '<CALLBACK_SECRET>');

// 订单列表查询
try {
    $request = new OrderListRequest();
    $request->setBusinessLine(BusinessLine::WAIMAI);
    $request->setActId(33);     // actId和businessLine至少有一个
    //$request->setStartTime(strtotime('2021-09-18'));
    //$request->setEndTime(strtotime('2021-09-19')); // 不能超过1天
    $request->setDate('2021-10-20');
    $request->setPage(1);
    $request->setLimit(20);
    $request->setQueryByPaytime();
    echo "\nrequest params: ";
    print_r($request->asArray());
    $response = $client->execute($request);
    echo "\nresponse: ";
    print_r($response);
} catch (GuzzleException $e) {
    echo $e->getMessage();
} catch (Exception $e) {
    echo $e->getMessage();
}