我有一个URI,它接受XML arg并返回XML结果。当我在浏览器中单独运行时,它可以很好地工作。
我需要将此脚本用作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;