我试过这段代码来访问数据但无法获取.任何人都知道如何添加此文件(Xml)
XML文件
1067 1070 135813
要拨打的代码
以下示例要求PHP版本大于5.5.x且库pecl_http => 2.5.3您可以通过https://pecl.php.net安装它
// Your API Key and secret $apiKey = "6355445214552444"; $sharedSecret = "5456842"; // Signature is generated by SHA256 (Api-Key + Shared Secret + Timestamp (in seconds)) $signature = hash("sha256", $apiKey.$sharedSecret.time()); // Example of call to the API $endpoint = "https://api.test.hotelbeds.com/hotel-api/1.0/status"; $request = new http\Client\Request("GET", $endpoint, [ "Api-Key" => $apiKey, "X-Signature" => $signature, "Accept" => "application/xml" ]); try { $client = new http\Client; $client->enqueue($request)->send(); // pop the last retrieved response $response = $client->getResponse(); if ($response->getResponseCode() != 200) { printf("%s returned '%s' (%d)\n", $response->getTransferInfo("effective_url"), $response->getInfo(), $response->getResponseCode() ); } else { printf($response->getBody()); } } catch (Exception $ex) { printf("Error while sending request, reason: %s\n",$ex->getMessage()); } ?>
任何人都可以指导我如何称为酒店床API?在哪里我犯了错误
谢谢