douershuang7356 2016-10-31 11:40
浏览 74

如何在php中调用expedia xml webservice

I try to call an expedia xml webservice in php, using curl. But how to send the XML data with post

sample request

<BookingConfirmRQ xmlns="http://www.expediaconnect.com/EQC/BC/2007/09">
    <Authentication username="mytestusername" password="mypwd"/>
    <Hotel id="7224658"/>    
    <BookingConfirmNumbers>
        <BookingConfirmNumber bookingID="252743459" bookingType="Book" confirmNumber="E2340589B" confirmTime="2013-12-30T23:45:00Z"/>
    </BookingConfirmNumbers>
</BookingConfirmRQ>

response

<BookingConfirmRS xmlns="http://www.expediaconnect.com/EQC/BC/2007/08">
    <Success/> OR FAIL
</BookingConfirmRS>

my code part

    $curl = curl_init();
    $url ="https://services.expediapartnercentral.com/eqc/bc";
    $data = array();//What will be data here and which formate

    switch ($method)
    {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);

            if ($data)
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data)
                $url = sprintf("%s?%s", $url, http_build_query($data));
    }

    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_USERPWD, "MYusername:MYpassword");

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($curl);

I am confused about What will be POST DATA here and which format? Is it right approach to use CURL or I have to use SoapClient() here? Please share your idea and solution. thanks

  • 写回答

1条回答 默认 最新

  • duanfan1965 2016-10-31 12:05
    关注

    your question is only. what is $data should be, isnt?

    you must know this ordinary html form. in this case i use login form

    <form method=POST> 
    <input type=text name=user value=admin>
    <input type=password name=pass value=SECRET>
    <input type=submit name=login value=sigin>
    </form>
    

    we can use curl to doing that with your curl script. and $data will be:

    $method='POST';
    $data = array(
      'user'=> 'admin',
      'pass'=>'SECRET',
      'login'=>'sigin'
    );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog