PHP code example of jucloud / easy-organization

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

    

jucloud / easy-organization example snippets




namespace App\Http\Controllers;

use JuCloud\EasyOrganization\EasyOrganization;

class IndexController
{
    protected $config = [
        'tianyancha' => [
            'default' => [
                // 选填-默认为正常模式。可选为: MODE_NORMAL, MODE_SANDBOX, MODE_SERVICE
                'mode' => EasyOrganization::MODE_NORMAL,
                // 必填-天眼查分配的 token
                'token' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
            ],       
        ],   
        'logger' => [ // optional
            'enable' => false,
            'file' => storage_path('logs/jucloud.organization.log'),,
            'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
            'type' => 'single', // optional, 可选 daily.
            'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
        ],
        'http' => [ // optional
            'timeout' => 5.0,
            'connect_timeout' => 5.0,
            // 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
        ],
    ];

    public function search()
    {   
        // keyword 关键词
        // page_size 每页大小
        // page_index 当前页数
        $result = EasyOrganization::tianyancha($this->config)->search([
            'keyword' => '',
            'page_size' => 0, //非必填
            'page_index' => 20, //非必填
        ]);

        return $result;
    }

}