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 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?