dongzhanjuan5141 2013-03-18 19:04
浏览 18
已采纳

PHP - 从带有XML字符串的URL返回

I have a URI that takes an XML arg and returns an XML result. Works superbly when I run it in a browser by itself.

I need to use this script as part of an AJAX query, so I was hoping to get a result from the URL and then just echo it out to the AJAX call. I've tried using fopen, but I don't get a result.

Is there a simple way to accomplish this? I've seen references to using a proxy, but can't find an example of how to do that with 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;
  • 写回答

2条回答 默认 最新

  • duansaxf095988 2013-03-18 19:06
    关注

    Use cURL to retrieve external website data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料