我有一段时间试图弄清楚这个 Yahoo Store API 的东西。我已经在互联网上搜索了示例,但几乎一无所获。我已经创建了我的请求:
String data = "";
data += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
data += "<ystorewsRequest>";
data += "<StoreID>" + storeID + "</StoreID>";
data += "<SecurityHeader>";
data += "<PartnerStoreContractToken>" + token + "</PartnerStoreContractToken>";
data += "</SecurityHeader>";
data += "<Version> 1.0 </Version>";
data += "<Verb> get </Verb>";
data += "<ResourceList>";
data += "<OrderListQuery>";
data += "<Filter>";
data += "<Include> all </Include>";
data += "</Filter>";
data += "<QueryParams>";
data += "<OrderID> 5441 </OrderID>";
data += "</QueryParams>";
data += "</OrderListQuery>";
data += "</ResourceList>";
data += "</ystorewsRequest>";
并尝试将数据发送到 API 文档中列出的 URL: https ://MyStoreID.order.store.yahooapis.com/V1/order (存储在字符串地址中)
url = new URL(address);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
conn.setRequestMethod("POST");
String urlParameters = "query=" + data;
DataOutputStream wr = new DataOutputStream (
conn.getOutputStream ());
wr.writeBytes (urlParameters);
wr.flush ();
wr.close ();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
line = rd.readLine();
rd.close();
结果我收到了这个错误;
java.io.IOException: Server returned HTTP response code: 400 for URL: https://MyStoreID.order.store.yahooapis.com/V1/order
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
我几乎完全迷失了这一点,因为雅虎提供了一些糟糕的文档,而且我找不到任何示例。有没有人尝试过使用来自 Java 的 Yahoo API 调用连接到 Yahoo Store?在这一点上的任何帮助表示赞赏。谢谢。