SDK

更新时间:

SDK

服务接入点

地域名称

地域ID

公网接入地址

华北3(张家口)

cn-zhangjiakou

iqs.cn-zhangjiakou.aliyuncs.com

示例代码

Java SDK

前提条件

已安装Java8及以上版本。

Maven依赖

通常建议使用最新版,以下内容仅为示例

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>iqs20240712</artifactId>
  <version>3.0.0</version>
</dependency>

SDK历史版本

  • 版本号: 3.0.0

    发布日期: 2025-01-17 10:54:17

  • 版本号: 2.0.5

    发布日期: 2025-01-10 14:31:44

  • 版本号: 2.0.4

    发布日期: 2025-01-06 14:22:13

  • 版本号: 2.0.3

    发布日期: 2024-12-13 16:40:21

  • 版本号: 2.0.2

    发布日期: 2024-12-05 14:33:24

  • 版本号: 2.0.1

    发布日期: 2024-11-25 13:17:47

  • 版本号: 2.0.0

    发布日期: 2024-11-22 16:29:56

调用代码

package com.alibaba.e2.linkedmall.lmops.test.services.ipaas;

import com.alibaba.e2.foundation.test.support.AssertUtils;
import com.aliyun.iqs20240712.Client;
import com.aliyun.iqs20240712.models.BicyclingDirectionNovaRequest;
import com.aliyun.iqs20240712.models.BicyclingDirectionNovaResponse;
import com.aliyun.iqs20240712.models.BicyclingDirectionNovaResponseBody;
import com.aliyun.iqs20240712.models.DrivingDirectionNovaRequest;
import com.aliyun.iqs20240712.models.DrivingDirectionNovaResponse;
import com.aliyun.iqs20240712.models.DrivingDirectionNovaResponseBody;
import com.aliyun.iqs20240712.models.GeoCodeRequest;
import com.aliyun.iqs20240712.models.GeoCodeResponse;
import com.aliyun.iqs20240712.models.GeoCodeResponseBody;
import com.aliyun.iqs20240712.models.NearbySearchNovaRequest;
import com.aliyun.iqs20240712.models.NearbySearchNovaResponse;
import com.aliyun.iqs20240712.models.NearbySearchNovaResponseBody;
import com.aliyun.iqs20240712.models.PlaceSearchNovaRequest;
import com.aliyun.iqs20240712.models.PlaceSearchNovaResponse;
import com.aliyun.iqs20240712.models.PlaceSearchNovaResponseBody;
import com.aliyun.iqs20240712.models.RgeoCodeRequest;
import com.aliyun.iqs20240712.models.RgeoCodeResponse;
import com.aliyun.iqs20240712.models.RgeoCodeResponseBody;
import com.aliyun.iqs20240712.models.TransitIntegratedDirectionRequest;
import com.aliyun.iqs20240712.models.TransitIntegratedDirectionResponse;
import com.aliyun.iqs20240712.models.TransitIntegratedDirectionResponseBody;
import com.aliyun.iqs20240712.models.WalkingDirectionNovaRequest;
import com.aliyun.iqs20240712.models.WalkingDirectionNovaResponse;
import com.aliyun.iqs20240712.models.WalkingDirectionNovaResponseBody;
import com.aliyun.tea.TeaException;
import org.junit.jupiter.api.Test;

import java.util.List;

public class IPaaSDemo {
    public static final String ACCESS_KEY_ID = "ALIBABA_CLOUD_ACCESS_KEY_ID";
    public static final String ACCESS_KEY_SECRET = "ALIBABA_CLOUD_ACCESS_KEY_SECRET";
    static {
        System.setProperty(ACCESS_KEY_ID, "***");
        System.setProperty(ACCESS_KEY_SECRET, "***");
    }

    /**
     * <b>description</b> :
     * <p>使用AK&amp;SK初始化账号Client</p>
     * @return Client
     *
     * @throws Exception
     */
    public static Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(System.getProperty(ACCESS_KEY_ID))
                .setAccessKeySecret(System.getProperty(ACCESS_KEY_SECRET));
        config.endpoint = "iqs.cn-zhangjiakou.aliyuncs.com";
        return new Client(config);
    }

    /**
     * 关键词搜索
     *
     * @throws Exception
     */
    @Test
    public void testPlaceSearchNova() throws Exception {
        Client client = createClient();
        PlaceSearchNovaRequest request = new PlaceSearchNovaRequest();
        request.setKeywords("东淀湿地");
//        request.setTypes("GAS_STATION|RESTAURANT|HOTEL|ATTRACTION");
        request.setRegion("0136");
        request.setPage(1);
        request.setSize(10);
        request.setCityLimit(true);

        try {
            PlaceSearchNovaResponse response = client.placeSearchNova(request);
            PlaceSearchNovaResponseBody body = response.getBody();
            List<PlaceSearchNovaResponseBody.PlaceSearchNovaResponseBodyData> data = body.getData();
            AssertUtils.assertNotNull(data.get(0).getAddress(), "address is not null");
            AssertUtils.assertNotNull(data.get(0).getCityName(), "city name is not null");
            AssertUtils.assertNotNull(data.get(0).getCityCode(), "city code is not null");
            AssertUtils.assertNotNull(data.get(0).getName(), "name is not null");
            AssertUtils.assertNotNull(data.get(0).getDistrictCode(), "DistrictCode is not null");
            AssertUtils.assertNotNull(data.get(0).getLatitude(), "Latitude is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 周边搜索
     *
     * @throws Exception
     */
    @Test
    public void testNearBySearchNova() throws Exception {
        Client client = createClient();
        NearbySearchNovaRequest request = new NearbySearchNovaRequest();
        request.setKeywords("湿地");
//        request.setTypes("GAS_STATION|RESTAURANT|HOTEL|ATTRACTION");
        request.setLongitude("116.635974");
        request.setLatitude("39.542041");
        request.setRadius(5000);
        request.setPage(1);
        request.setSize(10);
        request.setCityLimit(true);
        try {
            NearbySearchNovaResponse response = client.nearbySearchNova(request);
            NearbySearchNovaResponseBody body = response.getBody();
            List<NearbySearchNovaResponseBody.NearbySearchNovaResponseBodyData> data = body.getData();
            AssertUtils.assertNotNull(data.get(0).getAddress(), "address is not null");
            AssertUtils.assertNotNull(data.get(0).getCityName(), "city name is not null");
            AssertUtils.assertNotNull(data.get(0).getCityCode(), "city code is not null");
            AssertUtils.assertNotNull(data.get(0).getName(), "name is not null");
            AssertUtils.assertNotNull(data.get(0).getDistrictCode(), "DistrictCode is not null");
            AssertUtils.assertNotNull(data.get(0).getLatitude(), "Latitude is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 地理编码
     * @throws Exception
     */
    @Test
    public void testGeoCode() throws Exception {
        Client client = createClient();
        GeoCodeRequest request = new GeoCodeRequest();
        request.setCity("北京市");
        request.setAddress("北京大学餐厅");
        try {
            GeoCodeResponse response = client.geoCode(request);
            GeoCodeResponseBody body = response.getBody();
            List<GeoCodeResponseBody.GeoCodeResponseBodyData> data = body.getData();
            AssertUtils.assertNotNull(data.get(0).getCity(), "city is not null");
            AssertUtils.assertNotNull(data.get(0).getProvince(), "province is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 逆地理编码
     * @throws Exception
     */
    @Test
    public void testRegeoCode() throws Exception {
        Client client = createClient();
        RgeoCodeRequest request = new RgeoCodeRequest();
        request.setLongitude("116.310918");
        request.setLatitude("39.989027");
        try {
            RgeoCodeResponse response = client.rgeoCode(request);
            RgeoCodeResponseBody body = response.getBody();
            RgeoCodeResponseBody.RgeoCodeResponseBodyData data = body.getData();
            AssertUtils.assertNotNull(data.getCity(), "city is not null");
            AssertUtils.assertNotNull(data.getCountry(), "country is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 驾车路线规划
     * @throws Exception
     */
    @Test
    public void testDrivingDirectionNova() throws Exception {
        Client client = createClient();
        DrivingDirectionNovaRequest request = new DrivingDirectionNovaRequest();
        request.setOriginLongitude("116.310918");
        request.setOriginLatitude("39.989027");
        request.setDestinationLongitude("117.434446");
        request.setDestinationLatitude("40.90816");
        request.setCarType("GASOLINE_VEHICLE");
        request.setPlate("京A888888");
        try {
            DrivingDirectionNovaResponse response = client.drivingDirectionNova(request);
            DrivingDirectionNovaResponseBody body = response.getBody();
            DrivingDirectionNovaResponseBody.DrivingDirectionNovaResponseBodyData data = body.getData();
            AssertUtils.assertNotNull(data.getTaxiCost(), "taxi cost is not null");
            AssertUtils.assertNotNull(data.getCount(), "count is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 步行路线规划
     * @throws Exception
     */
    @Test
    public void testWalkingDirectionNova() throws Exception {
        Client client = createClient();
        WalkingDirectionNovaRequest request = new WalkingDirectionNovaRequest();
        request.setOriginLongitude("116.466485");
        request.setOriginLatitude("39.995197");
        request.setDestinationLongitude("116.46424");
        request.setDestinationLatitude("40.34542");
        try {
            WalkingDirectionNovaResponse response = client.walkingDirectionNova(request);
            WalkingDirectionNovaResponseBody body = response.getBody();
            WalkingDirectionNovaResponseBody.WalkingDirectionNovaResponseBodyData data = body.getData();
            AssertUtils.assertNull(data.getTaxiCost(), "taxi cost is null");
            AssertUtils.assertNotNull(data.getCount(), "count is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 骑行路线规划
     * @throws Exception
     */
    @Test
    public void testBicyclingDirectionNova() throws Exception {
        Client client = createClient();
        BicyclingDirectionNovaRequest request = new BicyclingDirectionNovaRequest();
        request.setOriginLongitude("116.466485");
        request.setOriginLatitude("39.995197");
        request.setDestinationLongitude("116.46424");
        request.setDestinationLatitude("40.34542");
        try {
            BicyclingDirectionNovaResponse response = client.bicyclingDirectionNova(request);
            BicyclingDirectionNovaResponseBody body = response.getBody();
            BicyclingDirectionNovaResponseBody.BicyclingDirectionNovaResponseBodyData data = body.getData();
            AssertUtils.assertNull(data.getTaxiCost(), "taxi cost is null");
            AssertUtils.assertEquals(data.getOriginLongitude(), "116.466485","data is equals.");
            AssertUtils.assertNotNull(data.getCount(), "count is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * 公交路线规划
     * @throws Exception
     */
    @Test
    public void testTransitIntegratedDirection() throws Exception {
        Client client = createClient();
        TransitIntegratedDirectionRequest request = new TransitIntegratedDirectionRequest();
        request.setOriginLongitude("116.466485");
        request.setOriginLatitude("39.995197");
        request.setDestinationLongitude("116.46424");
        request.setDestinationLatitude("40.34542");
        request.setOriginCity("北京市");
        request.setDestinationCity("北京市");
        try {
            TransitIntegratedDirectionResponse response = client.transitIntegratedDirection(request);
            TransitIntegratedDirectionResponseBody body = response.getBody();
            TransitIntegratedDirectionResponseBody.TransitIntegratedDirectionResponseBodyData data = body.getData();
            AssertUtils.assertNotNull(data.getCost(), "cost is not null");
            AssertUtils.assertNull(data.getCost().getTolls(), "tolls is null");
            AssertUtils.assertNull(data.getCost().getTollDistanceMeter(), "tollDistanceMeter is null");
            AssertUtils.assertEquals(data.getOriginLongitude(), "116.466485","data is equals.");
            AssertUtils.assertNotNull(data.getCount(), "count is not null");
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            _error.printStackTrace();
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Python SDK

前提条件

确保Python >= 3.7

安装SDK

通常建议使用最新版,以下内容仅为示例

pip install alibabacloud_iqs20240712==2.0.4

SDK历史版本

  • 版本号: 3.0.0

    发布日期: 2025-01-17 10:54:17

  • 版本号: 2.0.5

    发布日期: 2025-01-10 14:31:44

  • 版本号: 2.0.4

    发布日期: 2025-01-06 14:22:13

  • 版本号: 2.0.3

    发布日期: 2024-12-13 16:40:21

  • 版本号: 2.0.2

    发布日期: 2024-12-05 14:33:24

  • 版本号: 2.0.1

    发布日期: 2024-11-25 13:17:47

  • 版本号: 2.0.0

    发布日期: 2024-11-22 16:29:56

调用代码

# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_iqs20240712.client import Client as IQS20240712Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_iqs20240712 import models as iqs20240712_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class IPaaSOpenApiDemo:
    def __init__(self):
        # 设置环境变量
        # 更换为自己ak/sk
        os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'] = '***'
        os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] = '***'
        pass

    @staticmethod
    def create_client() -> IQS20240712Client:
        """
        初始化AK/SK
        """
        IPaaSOpenApiDemo.__init__(sys.argv[1:])

        """
        使用AK&SK初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
        # 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378659.html。
        config = open_api_models.Config(
            # 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。,
            access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
            # 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。,
            access_key_secret=os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
        )
        # Endpoint 请参考 https://api.aliyun.com/product/IQS
        config.endpoint = 'iqs.cn-zhangjiakou.aliyuncs.com'
        return IQS20240712Client(config)

    @staticmethod
    def main(args: List[str]) -> None:
        client = IPaaSOpenApiDemo.create_client()
        runtime = util_models.RuntimeOptions()
        headers = {}

        """
        测试关键词搜索接口
        """
        request = iqs20240712_models.PlaceSearchNovaRequest(
            keywords="东淀湿地",
            # types="GAS_STATION|RESTAURANT|HOTEL|ATTRACTION",
            region="0136",
            page=1,
            size=20,
            city_limit=True
        )
        try:
            response = client.place_search_nova_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试周边搜索接口
        """
        request = iqs20240712_models.NearbySearchNovaRequest(
            keywords="湿地",
            longitude="116.635974",
            latitude="39.542041",
            types="GAS_STATION|RESTAURANT|HOTEL|ATTRACTION",
            page=1,
            size=10,
            radius=3000,
            city_limit=True
        )
        try:
            response = client.nearby_search_nova_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试地理编码接口
        """
        request = iqs20240712_models.GeoCodeRequest(
            address="北京大学",
            city="北京市",
        )
        try:
            response = client.geo_code_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试逆地理编码接口
        """
        request = iqs20240712_models.RgeoCodeRequest(
            longitude="116.310918",
            latitude="39.989027",
        )
        try:
            response = client.rgeo_code_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试驾车路线规划接口
        """
        try:
            request = iqs20240712_models.DrivingDirectionNovaRequest(
                origin_longitude="116.434307",
                origin_latitude="39.90909",
                destination_longitude="117.434446",
                destination_latitude="39.90816",
                plate="",
                car_type="",
            )
            response = client.driving_direction_nova_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试步行路线规划接口
        """
        try:
            request = iqs20240712_models.WalkingDirectionNovaRequest(
                origin_longitude="116.466485",
                origin_latitude="39.995197",
                destination_longitude="116.46424",
                destination_latitude="40.020642",
            )
            response = client.walking_direction_nova_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试骑行路线规划接口
        """
        try:
            request = iqs20240712_models.BicyclingDirectionNovaRequest(
                origin_longitude="116.434307",
                origin_latitude="39.90909",
                destination_longitude="117.434446",
                destination_latitude="39.90816",
            )
            response = client.bicycling_direction_nova_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

        """
        测试公交路线规划接口
        """
        try:
            # 公交路线查询。
            request = iqs20240712_models.TransitIntegratedDirectionRequest(
                destination_city="深圳",
                destination_latitude="22.539211",
                destination_longitude="113.950961",
                origin_city="深圳",
                origin_latitude="22.641356",
                origin_longitude="113.919828",
            )
            response = client.transit_integrated_direction_with_options(request, headers, runtime)
            print(response.body)
        except Exception as error:
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    IPaaSOpenApiDemo.main(sys.argv[1:])

Go SDK

前提条件

Go环境版本必须不低于 1.10.x

安装SDK

go get github.com/alibabacloud-go/iqs-20240712

调用代码

以“关键词搜索”接口为例

package awesomeProject

// This file is auto-generated, don't edit it. Thanks.

import (
    "encoding/json"
    "fmt"
    openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
    iqs20240712 "github.com/alibabacloud-go/iqs-20240712/client"
    util "github.com/alibabacloud-go/tea-utils/v2/service"
    "github.com/alibabacloud-go/tea/tea"
    "os"
    "strings"
)

// Description:
//
// 使用AK&SK初始化账号Client
//
// @return Client
//
// @throws Exception
func CreateClient() (_result *iqs20240712.Client, _err error) {
    // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
    // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html。
    config := &openapi.Config{
       // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
       AccessKeyId: tea.String("***"),
       // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
       AccessKeySecret: tea.String("***"),
    }
    // Endpoint 请参考 https://api.aliyun.com/product/IQS
    config.Endpoint = tea.String("iqs.cn-zhangjiakou.aliyuncs.com")
    _result = &iqs20240712.Client{}
    _result, _err = iqs20240712.NewClient(config)
    return _result, _err
}

func _main(args []*string) (_err error) {
    client, _err := CreateClient()
    if _err != nil {
       return _err
    }

    request := &iqs20240712.PlaceSearchRequest{
       keywords: "餐厅",
       types:    "GAS_STATION|RESTAURANT|HOTEL|ATTRACTION",
    }
    runtime := &util.RuntimeOptions{}
    headers := make(map[string]*string)
    tryErr := func() (_e error) {
       defer func() {
          if r := tea.Recover(recover()); r != nil {
             _e = r
          }
       }()
       // 复制代码运行请自行打印 API 的返回值
       _, _err = client.PlaceSearchWithOptions(request, headers, runtime)
       if _err != nil {
          return _err
       }

       return nil
    }()

    if tryErr != nil {
       var error = &tea.SDKError{}
       if _t, ok := tryErr.(*tea.SDKError); ok {
          error = _t
       } else {
          error.Message = tea.String(tryErr.Error())
       }
       // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
       // 错误 message
       fmt.Println(tea.StringValue(error.Message))
       // 诊断地址
       var data interface{}
       d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
       d.Decode(&data)
       if m, ok := data.(map[string]interface{}); ok {
          recommend, _ := m["Recommend"]
          fmt.Println(recommend)
       }
       _, _err = util.AssertAsString(error.Message)
       if _err != nil {
          return _err
       }
    }
    return _err
}

func main() {
    err := _main(tea.StringSlice(os.Args[1:]))
    if err != nil {
       panic(err)
    }
}