Php 将API请求与用户而不是Http主机关联(Zillow API) 项目和问题说明 项目简介

Php 将API请求与用户而不是Http主机关联(Zillow API) 项目和问题说明 项目简介,php,ajax,xml,xmlhttprequest,zillow,Php,Ajax,Xml,Xmlhttprequest,Zillow,目前,我正在开发一个web应用程序,允许Zillow API订户在我的网站上向Zillow API发出请求,并能够以csv格式下载财产数据。我的web应用程序要求用户独立地向Zillow注册以接收他们的API密钥(ZWSID),这是每个API调用所必需的,Zillow将订阅者限制为每天1000个请求。因此,我的web应用程序代表用户发出API请求,并格式化数据供用户下载(这并不违反Zillow API条款和条件) 问题: 我面临的问题是,向Zillow API发出的每个请求都很可能包含我的URL

目前,我正在开发一个web应用程序,允许Zillow API订户在我的网站上向Zillow API发出请求,并能够以csv格式下载财产数据。我的web应用程序要求用户独立地向Zillow注册以接收他们的API密钥(ZWSID),这是每个API调用所必需的,Zillow将订阅者限制为每天1000个请求。因此,我的web应用程序代表用户发出API请求,并格式化数据供用户下载(这并不违反Zillow API条款和条件)

问题: 我面临的问题是,向Zillow API发出的每个请求都很可能包含我的URL作为请求的来源(可能还有用户代理或HTTP主机)。我担心这会被标记,Zillow会阻止我网站上的所有请求,即使它们是代表我的用户提出的。是否有办法将API请求与使用我的网站的人关联,并将我的网站作为源网站删除?换句话说,是否有任何方法可以阻止我的网站被包含在请求的标题中?详情请参阅下文

API请求和Zillow API后台 我的项目技术 因为API请求是代表用户发出的,所以对Zillow API的请求是在前端完成的(使用Ajax)。为了克服使用Ajax时出现的跨源请求错误,我必须导入“./jquery cross.js”文件

我必须向Zillow API发出请求的函数如下:

import $ from 'jquery'
import './jquery-cross.js'

const getReqWithSuccess = function(street, city, state) {
  return $.ajax({
    crossOrigin: true,
    url: `http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=X1-ZWz18mqy7m1ibv_ahuyo&address=${street}&citystatezip=${city}%2C+${state}&rentzestimate=true`,
    dataType: 'xml',
    method: 'GET'
  });
};
jquery-cross.js:

import jQuery from 'jquery'
var proxyJsonp = "https://script.google.com/macros/s/AKfycbwmqG55tt2d2FcT_WQ3WjCSKmtyFpkOcdprSITn45-4UgVJnzp9/exec";
jQuery.ajaxOrig = jQuery.ajax;
jQuery.ajax = function(a, b) {
function d(a) {
  a = encodeURI(a).replace(/&/g, "%26");
  return proxyJsonp + "?url=" + a + "&callback=?"
}
var c = "object" === typeof a ? a : b || {};
c.url = c.url || ("string" === typeof a ? a : "");
var c = jQuery.ajaxSetup({}, c),
e = function(a, c) {
  var b = document.createElement("a");
  b.href = a;
  return c.crossOrigin && "http" == a.substr(0, 4).toLowerCase() && "localhost" != b.hostname && "127.0.0.1" != b.hostname && b.hostname != window.location.hostname
}(c.url, c);
c.proxy && 0 < c.proxy.length && (proxyJsonp = c.proxy, "object" === typeof a ?
a.crossDomain = !0 : "object" === typeof b && (b.crossDomain = !0));
e && ("object" === typeof a ? a.url && (a.url = d(a.url), a.charset && (a.url += "&charset=" + a.charset), a.dataType = "json") : "string" === typeof a && "object" === typeof b && (a = d(a), b.charset && (a += "&charset=" + b.charset), b.dataType = "json"));
return jQuery.ajaxOrig.apply(this, arguments)
};
jQuery.ajax.prototype = new jQuery.ajaxOrig;
jQuery.ajax.prototype.constructor = jQuery.ajax;
从“jQuery”导入jQuery
var proxyJsonp=”https://script.google.com/macros/s/AKfycbwmqG55tt2d2FcT_WQ3WjCSKmtyFpkOcdprSITn45-4UgVJnzp9/exec";
jQuery.ajaxOrig=jQuery.ajax;
jQuery.ajax=函数(a,b){
职能d(a){
a=encodeURI(a).替换(/&/g,“%26”);
返回proxyJsonp+“?url=“+a+”&回调=?”
}
var c=“object”==a的类型:b |{};
c、 url=c.url | |(“字符串”==a的类型:”);
var c=jQuery.ajaxSetup({},c),
e=功能(a,c){
var b=document.createElement(“a”);
b、 href=a;
返回c.crossOrigin&&“http”==a.substr(0,4).toLowerCase()&&&“localhost”!=b.hostname&&“127.0.0.1”!=b.hostname&&b.hostname!=window.location.hostname
}(c.url,c);
c、 proxy&&0
Zillow API信息 API调用

我对PHP的了解有限,但请求似乎遵循这种格式。 API调用()的示例如下(其中ZWSID是Zillow订户密钥):

http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=&address=2114+Bigelow+Ave&citystatezip=西雅图%2C+WA
API响应

输出以XML格式返回:

 <SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd /vstatic/ae1bf8a790b67ef2e902d2bc04046f02/static/xsd/SearchResults.xsd">
    ...
</SearchResults:searchresults>

...
我愿意接受任何想法或解决办法,以删除与API请求相关的网站。谢谢你的帮助

 <SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd /vstatic/ae1bf8a790b67ef2e902d2bc04046f02/static/xsd/SearchResults.xsd">
    ...
</SearchResults:searchresults>