Google QPX Express

时间:2015-10-28 13:13:14

标签: c# asp.net google-api google-api-dotnet-client google-qpx-express-api

我正在尝试使用谷歌QPX Express API for ASP.NET,以便以低廉的价格阅读航班,但坚持使用以下代码。请与我分享任何想法。

  // Passengers
        PassengerCounts passengers = new PassengerCounts();
        passengers.AdultCount = 2;

        // Slice
        List<SliceInput> slices = new List<SliceInput>();

        SliceInput slice = new SliceInput();
        slice.Origin = "ADD";
        slice.Destination = "NBO";
        slice.Date = "2015-10-29";
        slices.Add(slice);


        // Options request
        TripOptionsRequest tripOptions = new TripOptionsRequest();
        tripOptions.Passengers = passengers;
        tripOptions.Solutions = 10;
        tripOptions.Slice = slices;

此致

1 个答案:

答案 0 :(得分:3)

您需要针对经过身份验证的服务发送请求并调用execute。

        QPXExpressService service = new QPXExpressService(new BaseClientService.Initializer()
        {
            ApiKey = "xxxx",
            ApplicationName = "Daimto QPX Express Sample",
        });

        TripsSearchRequest x = new TripsSearchRequest();
        x.Request = new TripOptionsRequest();
        x.Request.Passengers = new PassengerCounts { AdultCount = 2 };
        x.Request.Slice = new List<SliceInput>();
        x.Request.Slice.Add(new SliceInput() { Origin = "ADD", Destination = "NBO", Date = "2015-10-29" });
        x.Request.Solutions = 10;
        var result = service.Trips.Search(x).Execute();