我有一个接受 XML 参数并返回 XML 结果的 URI。当我在浏览器中单独运行它时,效果非常好。
我需要将此脚本用作 AJAX 查询的一部分,因此我希望从 URL 中获取结果,然后将其回显到 AJAX 调用中。我试过使用 fopen,但我没有得到结果。
有没有一种简单的方法可以做到这一点?我已经看到使用代理的参考,但找不到如何使用 php 执行此操作的示例。
$street = $_GET['street'];
$city = $_GET['city'];
$state = $_GET['state'];
$zip = $_GET['zip'];
$url = 'http://eligibility.cert.sc.egov.usda.gov/eligibility/eligibilityservice?eligibilityType=Property&requestString=';
$url_query = '%3C?xml%20version=%221.0%22?%3E%3CEligibility%20xmlns:xsi=%22http://www.w3.org/2001/XMLSchema-instance%22%20xsi:noNamespaceSchemaLocation=%22/var/lib/tomcat5/webapps/eligibility/Eligibilitywsdl.xsd%22%3E%3CPropertyRequest%20StreetAddress1=%22'.$street.'%20street%22%20StreetAddress2=%22%22%20StreetAddress3=%22%22%20City=%22'.$city.'%22%20State=%22'.$state.'%22%20County=%22%22%20Zip=%22'.$zip.'%22%20Program=%22RBS%22%3E%3C/PropertyRequest%3E%3C/Eligibility%3E';
$url_final = $url.''.$url_query;
$return = fopen($url_final);
echo $return;