-1

艾玛迪斯 api 返回401 client Credentials are invalid。请检查下面的代码。我将符号[]凭证字符串包含在内。

// here xxxxx are placeholders for real credentials (strings)
Amadeus amadeus = Amadeus.builder("[xxxxxx]","[xxxxxx]")
                    .setHostname("test").setHost("test.api.amadeus.com").setSsl(true).setLogLevel("debug").build();

//HttpHandler sh = new HttpHandler();

//FlightDestination[] des = sh.FlightDest();
//id = sh.id();

try {

    FlightDestination[] destination1 = amadeus.shopping.flightDestinations.get(Params.with("origin", "LON"));


    id = destination1[0].getOrigin();
    name = destination1[0].getDestination();
    email = destination1[0].getType();
}catch (ClientException e)
{
    id=e.getMessage();

}catch (NetworkException e)
{
    id = e.getMessage();

}catch (NotFoundException e)
{
    id = e.getMessage();
}catch (ServerException e)
{
   id =  e.getMessage();
}catch (ParserException e)
{
    id = e.getMessage();
}catch (ResponseException e)
{
    id = e.getMessage();
}
4

1 回答 1

1

您不需要[],您需要用 API_KEY 和 API_SECRET 替换它们,您可以按照本指南获得。

您可以在此处此处找到使用 Java SDK 的示例。

Amadeus amadeus = Amadeus.builder("API_KEY", "API_SECRET").build();


/* Find cheapest destinations from London */

FlightDestination[] flightDestinations = amadeus.shopping.flightDestinations.get(Params.with("origin", "LON"));

System.out.println(flightDestinations[0]);
于 2018-11-17T13:33:33.407 回答