0
<?php


                     $dest=explode(",",$destination);
                     $city= $dest[0];
                     $state= $dest[1];
                     $country= $dest[2];
                    // initiate curl and set options
                    $ch = curl_init();
                    $ver = 'v3/';
                    $method = 'list/';
                    $otherElementsStr = 'cid=55505&minorRev=5&customerUserAgent=Mozilla/4.0&customerIpAddress=172.16.82.13&locale=en_US&currencyCode=USD';
                    $apiKey = 'myapikey';  
                    $secret = 'mysecretkey';  
                    $timestamp = gmdate('U'); // 1200603038
                    //echo $timestamp;   
                    $sig = md5($apiKey . $secret . $timestamp);
                    $service = 'http://api.ean.com/ean-services/rs/hotel/';
                    $filter='&city='.$city.'&stateProvinceCode='.$state.'&countryCode='.$country.'&supplierCacheTolerance=MED_ENHANCED&arrivalDate='.$CheckInDate.'&departureDate='.$CheckOutDate;
                    $url =$service.$ver. $method ."?apiKey=".$apiKey."&sig=".$sig.$otherElementsStr.$filter ;
                    //echo $url;
                    $ch = curl_init();
                    curl_setopt($ch,CURLOPT_URL,$url);
                    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
                    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 4);
                    $json = curl_exec($ch);
                    if(!$json) {
                        echo curl_error($ch);
                    }
                    curl_close($ch);

                    //print_r(json_decode($json));

                    $array = json_decode($json, true);

                    $hotels = $array['HotelListResponse']['HotelList']['HotelSummary'];
                    $result='';
                    foreach ($hotels as $hotel) {
                        $result .= '<div class="hotel-listing-inner">
                                        <div class="list-hotel-1">
                                            <a href="#"><img src="http://images.travelnow.com/'. $hotel['thumbNailUrl'] . '" alt="" border="0" /></a>
                                            <span><a href="#">more photos</a></span>
                                        </div>
                                    <div class="list-hotel-right">
                                        <div class="charge-btn">
                                            <a href="#"><strong>'. number_format((float)$hotel['lowRate'], 2, '.', '') . '</strong>
                                                Per Night</a>
                                        </div>
                                        <div class="select-btn"><a href="#">select hotel</a></div>

                                    </div>    
                                        <div class="listing-content">
                                            <h2><a href="#">' . $hotel['name'] . '</a></h2>
                                            <div class="star-rating">
                                            <span class="stars">'. $hotel['hotelRating'] .'</span>

                                            </div>
                                            <h3>3.5</h3>
                                            <div class="rating-img"><img src="images/guest-reviews-2-5.png" alt="" border="0" />from 197 guest reviews</div>
                                        </div>
                                         <div class="city-name">
                                            <p>' . $hotel['address1'] . ',' . $hotel['postalCode'] . '</p>
                                            <p>' . $hotel['city'] . ','. $hotel['countryCode'] . '</p>
                                            <p><a href="#">Show on Map or Get Directions</a></p>
                                        </div>  
                                        <div class="hotel-locat">
                                        <span>
                                         ' . html_entity_decode($hotel['shortDescription'] ). '
                                         </span>
                                         <a href="#">more</a>
                                        </div>  
                                    </div>';
                    }


                    echo $result;

            ?>

这基本上是一个 EAN API 调用。现在我在同一页面上有一个按价格排序的锚标记 ,当用户单击该链接时,需要再次调用此 Web 服务,但过滤器参数不同。将对这个字符串进行一些更改。

$filter='&city='.$city.'&stateProvinceCode='.$state.'&countryCode='.$country.'&supplierCacheTolerance=MED_ENHANCED&arrivalDate='.$CheckInDate.'&departureDate='.$CheckOutDate;

所以我的问题是,当单击锚按钮时,如何通过更改 Web 服务的 URL 再次调用 php 代码。

4

0 回答 0