我在发送GeteBayDetails请求时遇到问题。 我对FindPopularItems,GeteBayTime等使用此代码(VB6,是的,我知道), 它工作正常。
Private Sub Command1_Click()
Dim httpCnct As XMLHTTP40
Dim xmlDoc As FreeThreadedDOMDocument40
Dim ebayurl As String
Dim devid As String
Dim appid As String
Dim certid As String
Dim xmlstring As String
Dim ebaytoken As String
Dim title As String
Dim itemid As String
Dim price As String
ebayurl = "http://open.api.sandbox.ebay.com/shopping?"
Set httpCnct = CreateObject("Msxml2.XMLHTTP.4.0")
httpCnct.open "POST", ebayurl, False
httpCnct.setRequestHeader "X-EBAY-API-APP-ID", appid
httpCnct.setRequestHeader "X-EBAY-API-VERSION", "857"
httpCnct.setRequestHeader "X-EBAY-API-SITE-ID", "3"
httpCnct.setRequestHeader "X-EBAY-API-CALL-NAME", "FindPopularItems"
httpCnct.setRequestHeader "X-EBAY-API-REQUEST-ENCODING", "XML"
xmlstring = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
"<FindPopularItemsRequest xmlns=""urn:ebay:apis:eBLBaseComponents"">" & _
"<QueryKeywords>Camera</QueryKeywords>" & _
"</FindPopularItemsRequest>"
httpCnct.send xmlstring 'xmlDoc Sending the raw string works.
...
但是当我稍微修改代码时,使用来自API测试工具的url,头文件和xml, 像这样:
ebayurl = "https://api.sandbox.ebay.com/ws/api.dll"
Set httpCnct = CreateObject("Msxml2.XMLHTTP.4.0")
httpCnct.open "POST", ebayurl, False
httpCnct.setRequestHeader "X-EBAY-API-APP-ID", appid
httpCnct.setRequestHeader "X-EBAY-API-CERT-NAME", certid
httpCnct.setRequestHeader "X-EBAY-API-VERSION", "903"
httpCnct.setRequestHeader "X-EBAY-API-SITE-ID", "0"
httpCnct.setRequestHeader "X-EBAY-API-CALL-NAME", "GeteBayDetails"
httpCnct.setRequestHeader "X-EBAY-API-REQUEST-ENCODING", "XML"
xmlstring = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
"<GeteBayDetailsRequest xmlns=""urn:ebay:apis:eBLBaseComponents"">" & _
"<RequesterCredentials> <eBayAuthToken>" & ebaytoken & "</eBayAuthToken>" & _
"</RequesterCredentials> </GeteBayDetailsRequest>"
httpCnct.send xmlstring 'xmlDoc Sending the raw string works.
我得到了
运行时错误&#39; -2146697208(800c0008)&#39;:指定的下载 资源失败
ebaytoken设置为我的token.devid,appid,certid在程序中设置得更早,并且在两个实例中都相同.xml没问题,标题和url是来自API测试工具的那些。 任何人都知道这里发生了什么? 感谢