PHP XML 요청 및 응답에 약간 손실되었습니다. 나는 USPS의 요금 계산기 API를 웹 사이트에 적용 할 필요가 있으며, 내가 알고있는 것은 그들이 제공하는 XML이다. 자, PHP를 사용하여 항목의 ZIP 및 무게를 API에 어떻게 제출할 수 있었는지 궁금합니다. PHP는 XML 요청 및 응답을 보내고받습니다.
- checkout.php을 : 지금 현재로
내가 가진 무엇 USPS의 API (여기에 내가 잃어버린입니다) 여기
$xml = rawurlencode('http://SERVER/PATH?API=RateV4&XML=<RateV4Request USERID="023TAHAR4995" ><Revision/>
<Package ID="1ST">
<Service>PRIORITY</Service>
<ZipOrigination>44106</ZipOrigination>
<ZipDestination>'.$zip.'</ZipDestination>
<Pounds>'.$pounds.'</Pounds>
<Container>NONRECTANGULAR</Container>
<Size>LARGE</Size>
<Width>15</Width>
<Length>30</Length>
<Height>15</Height>
<Girth>55</Girth>
</Package>
</RateV4Request>');
uspsRateCalculator.php
코드입니다
어떻게 "요청합니까?" 그런 다음 어떻게 응답을 얻을 수 있습니까? 결국
<?xml version="1.0" encoding="UTF-8"?>
<RateV4Response>
<Package ID="1ST">
<ZipOrigination>44106</ZipOrigination>
<ZipDestination>20770</ZipDestination>
<Pounds>1</Pounds>
<Ounces>8</Ounces>
<Container>NONRECTANGULAR</Container>
<Size>LARGE</Size>
<Width>15</Width>
<Length>30</Length>
<Height>15</Height>
<Girth>55</Girth>
<Zone>3</Zone>
<Postage CLASSID="1">
<MailService>Priority Mail<sup>&reg;</sup></MailService>
<Rate>24.85</Rate>
</Postage>
</Package>
</RateV4Response>
나는 나의 checkout.php 페이지에서를 얻을 필요가있다.