PHP SDK调用方法及示例。

服务调用所需依赖

composer require alibabacloud/address-purification-20191118

配置环境变量

阿里云SDK支持通过定义ALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRET环境变量来创建默认的访问凭证。调用接口时,程序直接访问凭证,读取您的访问密钥(即AccessKey)并自动完成鉴权。

重要

阿里云账号AccessKey拥有所有API的访问权限,建议您使用RAM用户进行API访问或日常运维,避免AccessKey泄露。

配置方法

配置环境变量ALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRET

  • Linux和macOS系统配置方法

    执行以下命令:

    export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>
    export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>

    <access_key_id>需替换为已准备好的AccessKey ID,<access_key_secret>替换为AccessKey Secret。

  • Windows系统配置方法

    1. 新建环境变量,添加环境变量ALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRET,并写入已准备好的AccessKey ID和AccessKey Secret。

    2. 重启Windows系统。

地址抽取

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class ExtractAddress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            // 设置地址抽取请求的接口名
            'action' => 'ExtractAddress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

ExtractAddress::main();

返回示例

string(191) "{"location_extract":[{"start":0,"end":8,"type":"LOC","word":"阿里巴巴西溪园区"}],"status":"OK","time_used":{"rt":{"location_extract":0.008560419082641602},"start":1678937689.8589857}}"

姓名抽取

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class ExtractName
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存在环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "张三";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'ExtractName',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

ExtractName::main();

返回示例

string(171) "{"person_extract":[{"start":0,"end":3,"type":"PER","word":"张三"}],"status":"OK","time_used":{"rt":{"person_extract":0.007501125335693359},"start":1678937857.677193}}"

电话号码抽取

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class ExtractPhone
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "张三1800****000";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'ExtractPhone',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

ExtractPhone::main();

返回示例

string(173) "{"phone_extract":[{"start":2,"end":13,"type":"TEL","word":"180****0000"}],"status":"OK","time_used":{"rt":{"phone_extract":0.009283781051635742},"start":1678938127.0899167}}"

行政区划解析

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetAddressDivisionCode
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetAddressDivisionCode',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetAddressDivisionCode::main();

返回示例

string(371) "{"division_info":{"divcode":"330110000000","division_name":"浙江省;杭州市;余杭区;"},"status":"OK","time_used":{"rt":{"basic_chunking":0.010630607604980469,"division_info":0.005403041839599609,"segment":0.0003552436828613281,"address_correct":0.0020055770874023438,"complete":0.00007677078247070312,"structure":0.00006628036499023438},"start":1678938277.3653004}}"

邮编识别

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetZipcode
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetZipcode',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetZipcode::main();

返回示例

string(288) "{"zipcode":"311100","status":"OK","time_used":{"rt":{"basic_chunking":0.01495504379272461,"zipcode":0.007276773452758789,"segment":0.0005021095275878906,"address_correct":0.002620220184326172,"complete":0.000102996826171875,"structure":0.00011849403381347656},"start":1678938377.1863396}}"

地址补全

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class CompleteAddress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'CompleteAddress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

CompleteAddress::main();

返回示例

string(480) "{"complete":"prov=浙江省\tcity=杭州市\tdistrict=余杭区\ttown=五常街道\troad=北侧道路\tpoi=阿里巴巴西溪园区\tpoi_list=阿里巴巴西溪园区\tdetail=poi:阿里巴巴西溪园区","status":"OK","time_used":{"rt":{"basic_chunking":0.016544818878173828,"segment":0.0004928112030029297,"address_correct":0.002981901168823242,"complete":0.00019621849060058594,"address_search":0.164764404296875,"structure":0.00010776519775390625},"start":1678938449.9231422}}"

地址纠错

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class CorrectAddress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'CorrectAddress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

CorrectAddress::main();

返回示例

string(224) "{"address_correct":["阿里巴巴西溪园区=poi"],"status":"OK","time_used":{"rt":{"basic_chunking":0.01656961441040039,"segment":0.00040650367736816406,"address_correct":0.0026862621307373047},"start":1678938516.8619475}}"

地址结构化

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class StructureAddress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'StructureAddress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

StructureAddress::main();

返回示例

string(302) "{"structure":"prov=浙江省\tcity=杭州市\tdistrict=余杭区\tpoi=阿里巴巴西溪园区\tpoi_list=阿里巴巴西溪园区\tdetail=poi:阿里巴巴西溪园区","status":"OK","time_used":{"rt":{"basic_chunking":0.01711559295654297,"structure":0.00012445449829101562},"start":1678938549.4122353}}"

多地址相似性判断

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetAddressSimilarity
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "杭州市阿里巴巴西溪园区;杭州市文一西路969号1号楼";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetAddressSimilarity',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetAddressSimilarity::main();

返回示例

string(384) "{"sim_level":{"distance":"806.86m","level":"none","address_a":"杭州市阿里巴巴西溪园区","address_b":"杭州市文一西路969号1号楼","is_same":false,"same_info":"prov=浙江省 city=杭州市 district=余杭区 town=五常街道 road=北侧道路 poi=阿里巴巴西溪园区"},"status":"OK","time_used":{"rt":{"sim_level":0.4123516082763672},"start":1678938668.682179}}"

物流面单信息提取

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class ExtractExpress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'ExtractExpress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

ExtractExpress::main();

返回示例

string(529) "{"express_extract":{"house_info":"","poi_info":"阿里巴巴西溪园区","town":"五常街道","city":"杭州市","district":"余杭区","tel":"","addr_info":"阿里巴巴西溪园区","per":"","prov":"浙江省"},"status":"OK","time_used":{"rt":{"basic_chunking":0.021270751953125,"segment":0.000637054443359375,"address_correct":0.0030400753021240234,"complete":0.00018548965454101562,"express_extract":0.0000209808349609375,"address_search":0.16134858131408691,"structure":0.00011014938354492188},"start":1678938704.1794796}}"

地址类型识别

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class ClassifyPOI
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'ClassifyPOI',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

ClassifyPOI::main();

返回示例

string(364) "{"poi_category":"房产园区与仓储#产业园区","status":"OK","time_used":{"rt":{"basic_chunking":0.017373323440551758,"segment":0.0005145072937011719,"poi_category":0.10416412353515625,"address_correct":0.003175020217895508,"complete":0.0001938343048095703,"address_search":0.16731476783752441,"structure":0.00012159347534179688},"start":1678938745.3905106}}"

POI预测

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class PredictPOI
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'PredictPOI',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

PredictPOI::main();

返回示例

string(353) "{"poi_predict":"阿里巴巴西溪园区","status":"OK","time_used":{"rt":{"basic_chunking":0.01753520965576172,"segment":0.0005474090576171875,"address_correct":0.0031142234802246094,"complete":0.0001862049102783203,"poi_predict":0.006916522979736328,"address_search":0.17387175559997559,"structure":0.00011134147644042969},"start":1678938801.3496034}}"

坐标系转换

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class TransferCoord
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "120.026268,30.279164";
        $body['SrcCoord'] = "gcj02";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'TransferCoord',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

TransferCoord::main();

返回示例

string(247) "{"coord_transfer":{"BD09":"120.032768,30.285238","CGCS2000":"120.021519,30.281543","WGS84":"120.021519,30.281543","GCJ02":"120.026268,30.279164"},"status":"OK","time_used":{"rt":{"coord_transfer":0.0032346248626708984},"start":1678938912.9115283}}"

通用经纬度查询(POI级别)

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetAddressGeocode
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetAddressGeocode',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetAddressGeocode::main();

返回示例

string(421) "{"offline_geocode":{"wgs84":"120.01842160190826,30.28575692671618","level":"poi","gcj02":"120.023164,30.28337"},"status":"OK","time_used":{"rt":{"basic_chunking":0.016934871673583984,"div_search":0.0010542869567871094,"segment":0.00046372413635253906,"geocode":0.005757570266723633,"address_correct":0.002730131149291992,"address_search":0.1618194580078125,"structure":0.00011229515075683594},"start":1678939072.4625604}}"

地址异常检测

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetAddressEvaluate
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetAddressEvaluate',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetAddressEvaluate::main();

返回示例

string(245) "{"address_evaluate":{"errors":"行政区划缺失;路名路号缺失"},"status":"OK","time_used":{"rt":{"basic_chunking":0.016921281814575195,"address_evaluate":0.00017523765563964844,"segment":0.000438690185546875},"start":1678939122.942952}}"

地址搜索

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetAddressSearch
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetAddressSearch',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetAddressSearch::main();

返回示例

string(1147) "{"address_search":[{"address":"西溪五期北侧道路","name":"阿里巴巴西溪C区","std_addr":"浙江省 杭州市 余杭区 五常街道  北侧道路   阿里巴巴西溪C区"},{"address":"文一西路969号","name":"阿里巴巴西溪A区","std_addr":"浙江省 杭州市 余杭区 五常街道  文一西路 969号  阿里巴巴西溪A区"},{"address":"溪望路","name":"阿里巴巴西溪B区","std_addr":"浙江省 杭州市 余杭区 五常街道  溪望路   阿里巴巴西溪B区"},{"address":"文一西路969号阿里巴巴西溪A区","name":"阿里巴巴西溪A区(A5楼)","std_addr":"浙江省 杭州市 余杭区 五常街道  文一西路 969号  阿里巴巴西溪A区(A5楼)"},{"address":"文一西路969号阿里巴巴西溪A区","name":"阿里巴巴西溪A区(A4楼)","std_addr":"浙江省 杭州市 余杭区 五常街道  文一西路 969号  阿里巴巴西溪A区(A4楼)"}],"status":"OK","time_used":{"rt":{"basic_chunking":0.01698446273803711,"segment":0.0005893707275390625,"address_correct":0.0024530887603759766,"address_search":0.14429116249084473,"structure":0.00011181831359863281},"start":1678939163.2801683}}"

地址输入联想

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class GetInputSearch
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'GetInputSearch',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

GetInputSearch::main();

返回示例

string(741) "{"input_search":["浙江省 杭州市 余杭区 五常街道  文一西路   阿里巴巴西溪园区(公交站)","浙江省 杭州市 余杭区 五常街道  聚橙路   驿客酒店式公寓(阿里巴巴西溪园区店)","浙江省 杭州市 余杭区 五常街道  向往街 199号 1号楼 同悦酒店(杭州阿里巴巴西溪园区店)","浙江省 杭州市 余杭区 五常街道  文一西路   阿里巴巴西溪园区(蔡家阁)(公交站)","浙江省 杭州市 余杭区 五常街道  贺翠路  1号楼 杭州忆家公寓酒店(阿里巴巴西溪园区店)"],"status":"OK","time_used":{"rt":{"basic_chunking":0.017215251922607422,"input_search":0.027119874954223633,"structure":0.00011205673217773438},"start":1678939207.8285642}}"

门址标准化

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class StreetStd
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'StreetStd',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

StreetStd::main();

返回示例

string(426) "{"street_std":"prov=浙江省\tcity=杭州市\tdistrict=余杭区\ttown=五常街道\troad=文一西路\troadno=969号\tpoi=阿里巴巴西溪园区","status":"OK","time_used":{"rt":{"basic_chunking":0.016364336013793945,"street_std":0.00029277801513671875,"segment":0.0005488395690917969,"address_correct":0.002571582794189453,"address_search":0.1461029052734375,"structure":0.000102996826171875},"start":1678939421.2437048}}"

语音地址输入识别

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class InputAsrAddress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'InputAsrAddress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

InputAsrAddress::main();

返回示例

string(381) "{"asr_address_input":{"house_info":"","struct":"prov=浙江省\tcity=杭州市\tdistrict=余杭区\tpoi=阿里巴巴西溪园区","poi_info":"阿里巴巴西溪园区","town":"","city":"杭州市","district":"余杭区","addr_info":"阿里巴巴西溪园区","prov":"浙江省"},"status":"OK","time_used":{"rt":{"asr_address_input":0.03881049156188965},"start":1678939666.2516294}}"

多源地址归一

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class OneIdAddress
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'OneIdAddress',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

OneIdAddress::main();

返回示例

{'RequestId': '7EF87685-675C-1753-BED1-3181D1F4D565', 'Data': '{"online_address_unify":"82310db47579d1e4ef4484d7ce3f0b76","status":"OK","time_used":{"rt":{"basic_chunking":0.010370254516601562,"online_address_unify":0.0012214183807373047,"segment":0.0004582405090332031,"address_correct":0.0020546913146972656,"address_search":0.1227867603302002,"structure":0.0000743865966796875},"start":1675414152.5409853}}'}

对话上下文地址推理

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class AddressInference
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "我在阿里巴巴门口被车撞了,滨江区的";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'AddressInference',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

AddressInference::main();

返回示例

string(838) "{"address_inference":[{"address":"网商路699号","divcode":"330108","name":"阿里巴巴滨江园区","id":"B0FFG083SL","lxly":"30.1896,120.190371","std_addr":"浙江省 杭州市 滨江区 长河街道  网商路 699号  阿里巴巴滨江园区"},{"address":"文一西路969号","divcode":"330110","name":"阿里巴巴西溪A区","id":"B023B1D4BX","lxly":"30.278984,120.025746","std_addr":"浙江省 杭州市 余杭区 五常街道  文一西路 969号  阿里巴巴西溪A区"},{"address":"溪望路","divcode":"330110","name":"阿里巴巴西溪B区","id":"B0FFGUEOJ9","lxly":"30.275962,120.027276","std_addr":"浙江省 杭州市 余杭区 五常街道  溪望路   阿里巴巴西溪B区"}],"status":"OK","time_used":{"rt":{"dialog_extract":0.009522676467895508,"address_inference":0.6170024871826172},"start":1678939524.550949}}"

高精度经纬度查询(楼栋级别)

请求示例

<?php

require __DIR__ . '/vendor/autoload.php';

use AlibabaCloud\OpenApiUtil\OpenApiUtilClient;
use AlibabaCloud\SDK\Addresspurification\V20191118\Addresspurification;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\OpenApiRequest;
use Darabonba\OpenApi\Models\Params;

/**
 * author: shuaicheng
 * Date: 2023/3/7 4:10 PM
 */
class HpGeocode
{
    /**
     * 使用AccessKey ID和AccessKey Secret初始化账号Client
     * @param string $accessKeyId <your-access-key-id>
     * @param string $accessKeySecret <your-access-key-secret>
     * @return Addresspurification Client
     */
    public static function createClient()
    {
        $config = new Config();         
        // 强烈建议不要把AccessKey ID和AccessKey Secret保存到工程代码里,否则可能导致AccessKey泄露,威胁您账号下所有资源的安全。         
        // 本示例以将AccessKey ID和AccessKey Secret保存到环境变量为例说明。运行本代码示例之前,请先配置环境变量。
        $config->accessKeyId = getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        $config->accessKeySecret = getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
        $config->endpoint = "address-purification.cn-hangzhou.aliyuncs.com";
        return new Addresspurification($config);
    }

    public static function main()
    {
        $client = self::createClient();

        $body = [];
        // 设置为您的appkey
        $body['AppKey'] = "<your-appKey>";
        // 设置城市名
        $body['DefaultCity'] = "杭州市";
        // 设置区名
        $body['DefaultDistrict'] = "余杭区";
        // 设置省份名
        $body['DefaultProvince'] = "浙江省";
        // 固定值为addrp
        $body['ServiceCode'] = "addrp";
        // 设置请求文本
        $body['Text'] = "阿里巴巴西溪园区";
        $req = new OpenApiRequest([
            'body' => OpenApiUtilClient::parseToMap($body),
        ]);
        $params = new Params([
            'action' => 'HpGeocode',
            'version' => '2019-11-18',
            'protocol' => 'HTTPS',
            'pathname' => '/',
            'method' => 'POST',
            'authType' => 'AK',
            'style' => 'RPC',
            'reqBodyType' => 'formData',
            'bodyType' => 'json',
        ]);
        $runtime = new RuntimeOptions([
            'maxIdleConns' => 3,
            'connectTimeout' => 10000,
            'readTimeout' => 10000
        ]);
        $map = $client->callApi($params, $req, $runtime);
        /**
         *  public $headers;
         *  public $statusCode;
         *  public $body;
         */
        var_dump($map["body"]["Data"]);
    }
}

HpGeocode::main();

返回示例

string(154) "{"hpgeocode":{"level":"poi","gcj02":"120.024408,30.275953"},"status":"OK","time_used":{"rt":{"hpgeocode":0.18193364143371582},"start":1678939622.3214366}}"