Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ebay Soap API call with CF

Status
Not open for further replies.

FALCONSEYE

Programmer
Jul 30, 2004
1,158
US
has anyone worked with ebay's Soap API ? I saw some example CF code at developer.ebay.com but it doesn't work for some reason. Anyone know how to get a eBayAuthToken ?
thanks

 
The code probably works differently than you expect. I've seen the same code on several tutorials so i'm sure it works. what do you have so far?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
this is what i have so far. As you will realize, ebayAuthToken variable is "". I don't know how to get it?
Ebay assigned me the AppID, DevID, and CertID which i have to put into the request header. All i am trying to is to connect to the sandbox and get two things : 1. local time on ebay and 2. Get everything for a specific itemID:4567762923 which is a VW touareg posted on the site.
what am i doing wrong? :p

<cfset endpoint="<cfset callName="geteBayOfficialTime">
<cfset AppID="BU.........VT7E621C384L2">
<cfset DevID="R..........3T1K414W3L22ZLN">
<cfset CertID="C1........G31$15O21726J-XYB3AF1J">
<cfset eBayAuthToken="">
<cfset version="419">
<cfset routing="default">
<cfset SiteID=0>

<cfscript>
ebayWS = CreateObject("webservice", "</cfscript>

<!--- create special xml header for authentification --->
<cfset methodToCall = "geteBayOfficialTime">
<Cfset methodToCall1 = "getItem">
<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)>


<cflock type="READONLY" name="#server.coldfusion.productVersion#" timeout="10">
<cfset cfmx_version=Replace(Replace(ListDeleteAt(server.coldfusion.productVersion,4),",","","all")," ","","all")>
</cflock>

<cfscript>
addSOAPRequestHeader(ebayWS, "urn:ebay:apis:eBLBaseComponents", "RequesterCredentials", "#ebayXMLObj#", false);
</cfscript>

<cfscript>
// set the end point
ebayWS._setProperty("javax.xml.rpc.service.endpoint.address","
// build geteBayOfficialTimeRequest..
timeRequest = StructNew();
timeRequest.version = variables.version;
</cfscript>
<cfscript>
ebayWS._setProperty("javax.xml.rpc.service.endpoint.address","itemRequest = "4567762923";
</cfscript>


<!--- call the service --->
<cfinvoke webservice="#ebayWS#" method="#methodToCall#" returnvariable="temp">
<cfinvokeargument name="geteBayOfficialTimeRequest" value="#timeRequest#">
</cfinvoke>
<cfinvoke webservice="#ebayWS#" method="#methodToCall1#" returnvariable="temp1">
<cfinvokeargument name="GetItemRequest" value="#itemRequest#">
</cfinvoke>
<Cfoutput>#temp1#</Cfoutput>
<!--- save the output //--->
<cfset eBayDateTime=temp.getTimeStamp().getTime()>

<p>Official eBay Date(dd.mm.yyyy)/Time(HH:mm:ss): <cfoutput>#lsDateFormat(eBayDateTime,"dd.mm.yyyy")# #lsTimeFormat(eBayDateTime,"HH:mm:ss")#</cfoutput></p>

 
I'm not sure where it was you got your sample code from but this is some code i found from ebay's API call example.

Code:
<cftry>
	<cfscript>
		// create the object used to send XML to eBay API
		xmlObjServer = CreateObject("COM", "msxml2.serverxmlhttp");

		// set the request headers for the HTTP request
		if (variables.sendToSandbox eq '1') { // send to the sandbox for testing
			// set SANDBOX variables in request headers
			variables.Urlxml="[URL unfurl="true"]https://api.sandbox.ebay.com/ws/api.dll";[/URL]
			variables.logPass = "YOURPASSWORDHERE";
			xmlObjServer.open( "post", variables.Urlxml,"false");
			xmlObjServer.setRequestHeader("X-EBAY-API-SESSION-CERTIFICATE", variables.logPass);
			xmlObjServer.setRequestHeader("X-EBAY-API-COMPATIBILITY-LEVEL", "YOUR-COMPATLEVEL-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-DEV-NAME", "YOUR-DEVNAME-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-APP-NAME", "YOUR-APPNAME-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-CERT-NAME", "YOUR-CERTNAME-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-MOTORATTRIBUTES", "1");
			xmlObjServer.setRequestHeader("X-EBAY-API-CALL-NAME", variables.callName);
			xmlObjServer.setRequestHeader("X-EBAY-API-SITEID", variables.siteId);
			xmlObjServer.setRequestHeader("X-EBAY-API-DETAIL-LEVEL", variables.detailLevel);
		} else {
			// set PRODUCTION variables in request headers
			variables.Urlxml="[URL unfurl="true"]https://api.ebay.com/ws/api.dll";[/URL]
			variables.logPass = "YOURPASSWORDHERE";
			xmlObjServer.open( "post", variables.Urlxml,"false");
			xmlObjServer.setRequestHeader("X-EBAY-API-SESSION-CERTIFICATE", variables.logPass);
			xmlObjServer.setRequestHeader("X-EBAY-API-COMPATIBILITY-LEVEL", "YOUR-COMPATLEVEL-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-DEV-NAME", "YOUR-DEVNAME-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-APP-NAME", "YOUR-APPNAME-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-CERT-NAME", "YOUR-CERTNAME-HERE");
			xmlObjServer.setRequestHeader("X-EBAY-API-MOTORATTRIBUTES", "1");
			xmlObjServer.setRequestHeader("X-EBAY-API-CALL-NAME", variables.callName);
			xmlObjServer.setRequestHeader("X-EBAY-API-SITEID", variables.siteId);
			xmlObjServer.setRequestHeader("X-EBAY-API-DETAIL-LEVEL", variables.detailLevel);
		}
	</cfscript>

	<!--- send the XML call itself via the COM Obj. variables.xml contains the XML for the API call itself. --->
	<cfset x = xmlObjServer.send( variables.xml )>

	<!--- retrieve the returned XML from the Obj --->
	<cfset variables.respXml = xmlObjServer.responseXML>
	<cfset variables.respXml = variables.respXml.xml>

	<cfset xmlObjServer = "">

	<!--- Log the API call if so desired --->
	<cfinclude template="LogAPICall.cfm">

	<cfcatch>
		<!--- perform exception handling here --->
	</cfcatch>
</cftry>

<!--- process the returned XML, turning it into a struct-type object.
	see [URL unfurl="true"]http://tutorial131.easycfm.com/[/URL] for source code for the custom tag. --->
<cf_soxml action="XML2CF" input="#variables.respXml#" output="variables.Obj" progId="Msxml2.DOMDocument.4.0">

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
how "doesn't it work"? errors out or what?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top