eBay API获取结果示例无法正常工作

时间:2013-08-19 16:14:18

标签: ebay

我正在尝试为ebay api进行coldfusion工作。我没有使用沙箱变量,而是我生成的生产变量。我没有在网上看到大量的CF示例,ebay开发者网站对我来说非常混乱。当我运行此示例时,我收到错误:

无法从网址读取WSDL:http://www.ebay.com/webservices/latest/ebaySvc.wsdl

此时我迷失了。任何帮助将不胜感激。以下是我尝试在下面运行的示例:

<!--- set some vars ---> 
<cfset endpoint="https://api.ebay.com/wsapi"> 
<cfset callName="geteBayOfficialTime"> 
<cfset AppID="xxx"> 
<cfset DevID="xxx"> 
<cfset CertID="xxx"> 
<cfset eBayAuthToken="xxx"> <!--- this is a really long string by the way ---> 
<cfset version="419"> 
<cfset routing="default"> 
<cfset SiteID=0> 
<!--- 77 Germany, 0 USA ---> 

<cfscript> 
// get ebay wsdl file, this could take 1 -10 minutes for the first request or after a CFMX reboot 
ebayWS = CreateObject("webservice", "     http://developer.ebay.com/webservices/latest/ebaySvc.wsdl"); 
</cfscript> 

<!--- create special xml header for authentification ---> 
<cfset methodToCall = "GetSearchResults"> 
<cfsavecontent variable="ebayHeaderXML"> 
<cfoutput> 
<ebl:RequesterCredentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents"> 
<ebl:eBayAuthToken>#variables.eBayAuthToken#</ebl:eBayAuthToken> 
<ebl:Credentials> 
<ebl:DevId>#variables.DevID#</ebl:DevId> 
<ebl:AppId>#variables.AppID#</ebl:AppId> 
<ebl:AuthCert>#variables.CertID#</ebl:AuthCert> 
</ebl:Credentials> 
</ebl:RequesterCredentials> 
</cfoutput> 
</cfsavecontent> 
<cfset ebayXMLObj = xmlparse(ebayHeaderXML)> 

<cfscript> 
// set the header using addSOAPRequestHeader.. an added function to CF MX 7.0 
addSOAPRequestHeader(ebayWS, "urn:ebay:apis:eBLBaseComponents", "RequesterCredentials",     "#ebayXMLObj#", false); 
</cfscript> 

<cfscript> 
// set the end point using javas _setProperty 
ebayWS._setProperty("javax.xml.rpc.service.endpoint.address","https://api.ebay.com/wsapi?    callname=#methodToCall#&siteid=#SiteID#&appid=#AppID#&version=#version#&Routing=#routing#")    ; 

// build geteBayqueryrequest.. 
queryrequest = StructNew(); 
queryrequest.query = "ipod nano"; 
queryrequest.version = variables.version; 
queryrequest.ExpandSearch = "True"; 
</cfscript> 

<!--- <cfscript> 
queryrequest = XmlNew(); 
queryrequest.xmlRoot = XmlElemNew(queryrequest,"GetSearchResultsRequest"); 
queryrequest.GetSearchResultsRequest.XmlChildren[1] = XmlElemNew(queryrequest,"Query"); 
queryrequest.GetSearchResultsRequest.Query.XmlText = "ipod nano"; 
</cfscript> 
<cfdump var=#queryrequest#> 
---> 
<!--- call the webservice ---> 
<cfinvoke webservice="#ebayWS#" method="#methodToCall#" returnvariable="thisRequest"> 
<cfinvokeargument name="getSearchResultsRequest" value="#queryrequest#"> 
</cfinvoke> 

<!--- save the output //---> 
<!--- <cfdump var="#thisRequest#"> ---> 
<cfdump var="#thisRequest.getSearchResultItemArray()#"> 
<cfdump var="#thisRequest.getSearchResultItemArray().getSearchResultItem()#"> 
<cfdump var="#thisRequest.getSearchResultItemArray().getSearchResultItem().getItem(1)#"> 
<cfoutput>#var#</cfoutput> 

2 个答案:

答案 0 :(得分:0)

Ebay有时会有点乱,但坚持下去。

您的问题是,您所关注的指南会提供旧/错链接。 (http://www.ebay.com/webservices/latest/ebaySvc.wsdl)。 当前链接为http://developer.ebay.com/webservices/latest/eBaySvc.wsdl。您可以在Ebay's guide pages

找到更多信息

答案 1 :(得分:0)

我在这里写了一个开源cfc:https://github.com/a453803/cf_ebay

这简要介绍了如何获取您的易趣凭据并使用它们来处理与易趣的交易。在这种情况下,这是一个时间请求,但我计划使用新功能进行扩展。

看看,如果您需要任何帮助,或者您希望实施任何特定功能,请告知我们。