俺的朋友有給俺一個JS的ebay api,不過俺測試不成功,一直沒有回傳.
可以請各位大大們給予小弟指導一下嗎??
俺JS比較差~~!
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ebay api test</title>
<link rel="stylesheet" type="text/css" href="css/skeleton.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<div style="text-align:center;margin-top:30px">
<form name="form_sort" method="post">
<input type='button' value='ebay api' onclick="ebayapi()" />
</form>
</div>
<script language="JavaScript">
function ebayapi(){
var xml_1 = '<?xml version="1.0" encoding="UTF-8"?>';
xml_1 += '<GetItemTransactionsRequest xmlns="urn:ebay:apis:eBLBaseComponents"><ItemID>321072879984</ItemID>'+
'<RequesterCredentials>'+
'<eBayAuthToken>AgAAA....</eBayAuthToken>'+
'</RequesterCredentials>'+
'<WarningLevel>High</WarningLevel>'+
'</GetItemTransactionsRequest>';
console.log('ebay-xml:'+xml_1);
/***call ebay start ***********/
// Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open('POST', 'https://api.sandbox.ebay.com/ws/api.dll', true);
//Set the Headers
xmlHttpReq.setRequestHeader('Content-Type','text/xml');
xmlHttpReq.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL','805');
xmlHttpReq.setRequestHeader('X-EBAY-API-DEV-NAME','e....');
xmlHttpReq.setRequestHeader('X-EBAY-API-APP-NAME','ed21...');
xmlHttpReq.setRequestHeader('X-EBAY-API-CERT-NAME','0c...');
xmlHttpReq.setRequestHeader('X-EBAY-API-CALL-NAME','GetItemTransactions');
xmlHttpReq.setRequestHeader('X-EBAY-API-SITEID','0');
//get the XML Request string
xmlHttpReq.send(xml_1);
//When the response is available, update the response text
xmlHttpReq.onreadystatechange = function() {
console.log('ebay-readyState:'+xmlHttpReq.readyState);
if (xmlHttpReq.readyState == 4) {
console.log('ebay-response:'+xmlHttpReq.responseText);
}
}
/***call ebay end ***********/
return false;
}
</script>
麻煩各位大大 大神們幫忙了
我接到的回應如下供參考
<pre class="c" name="code">
<?xml version="1.0" encoding="UTF-8"?>
<GetItemTransactionsResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2013-03-28T08:43:23.713Z</Timestamp>
<Ack>Failure</Ack>
<Errors>
<ShortMessage>Auth token is invalid.</ShortMessage>
<LongMessage>Validation of the authentication token in API request failed.</LongMessage>
<ErrorCode>931</ErrorCode>
<SeverityCode>Error</SeverityCode>
<ErrorClassification>RequestError</ErrorClassification>
</Errors>
<Version>815</Version>
<Build>E815_CORE_BUNDLED_15860922_R1</Build>
</GetItemTransactionsResponse>