doushan6692 2017-02-16 09:48
浏览 33
已采纳

使用CURL的所有酒店位置的Skyscanner API

I am trying to fetch geo catalogue data from skyscanner api. I have read documentation http://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview

I have created api key. I am hitting api successfully and getting result same as on the http://business.skyscanner.net/portal/en-GB/Documentation/HotelsLivePricingQuickStart

I am hitting:-

http://partners.api.skyscanner.net/apiservices/hotels/autosuggest/v2/UK/GBP/en-GB/.$cityname.?apikey=prtl6749387986743898559646983194"

I want to get responce in JSON. Is it possible??

I have successfully get flight live prices here is link [Get error in using skyscanner Api of flight pricing in php using POST method.

  • 写回答

1条回答 默认 最新

  • dongxuxian6930 2017-02-16 10:11
    关注
    <?php
    $checkin_date = "2017-05-05";
    $checkout_date = "2017-05-08";
    $guests = 10;
    $rooms=  4;
    $country_iso_code = "UK";
    $country_currency = "EUR";
    $locale_lang = "en-GB";
    $url = "http://partners.api.skyscanner.net/apiservices/hotels/liveprices/v2/$country_iso_code/$country_currency/$locale_lang/27539733/$checkin_date/$checkout_date/$guests/$rooms?apiKey=prtl6749387986743898559646983194";
    
    $ch = curl_init();
    $http_header = ["Content_type : application/json"];
    $options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTPHEADER => $http_header
    ];
    curl_setopt_array($ch, $options);
    $response = curl_exec($ch);
    curl_close($ch);
    
    var_dump($response);
    

    //Response in Json

    This is just basic code how you hit the api of skyscanner to get the data in json format using curl

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料