PHP code example of yuanfenju / sdk

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

    

yuanfenju / sdk example snippets




uanfenju\Sdk\Client;
use Yuanfenju\Sdk\Exception\ApiException;

// 1. 初始化 SDK
$client = new Client('你的_API_KEY');

try {
    // 2. 调用生辰分析接口
    $result = $client->getBaziPaipan([
        'name'   => '张三',
        'sex'    => 1,           // 1女 0男
        'type'   => 1,           // 0农历 1公历
        'year'   => 1990,
        'month'  => 1,
        'day'    => 1,
        'hours'  => 8,
        'minute' => 0
    ]);

    print_r($result);

} catch (ApiException $e) {
    echo "请求失败: " . $e->getMessage();
}

$result = $client->request('/api/v1/Bazi/hehun', $params, 'POST');

examples/
├── bazi_paipan.php    # 八字排盘
├── bazi_cesuan.php    # 八字测算
├── bazi_yunshi.php    # 八字运势