本接口採用標準 XML 結構封裝新聞數據,最外層以 <info> 標籤包裹,內部每一則新聞對應一個 <rec> 節點。各字段含義如下:
<info>
<rec>
<depID>所屬欄目</depID>
<smallClassID>所屬信息單位</smallClassID>
<type>信息發布形式</type>
<keyWord>關鍵字</keyWord>
<title>新聞標題</title>
<author>作者</author>
<original>原出處</original>
<content>新聞內容</content>
</rec>
<rec>
...(可包含多則新聞)
</rec>
</info>
| 字段名 | 名稱 | 類型 | 取值說明 | 上傳說明 |
|---|---|---|---|---|
| depID | 所屬欄目 | Int(4) | 代碼 | 不能為空 |
| smallClassID | 所屬信息單位 | Nvarchar(25) | 代碼 | 不能為空 |
| type | 信息發布形式 | Nvarchar(7) | 重要信息=1;彈出信息=2;熱點信息=3,可複選多個並以「,」分隔,如:1,2,3 | 代碼(多個用逗號分隔) |
| keyWord | 關鍵字 | Nvarchar(50) | 多個以「,」分隔,如:keyWord1,keyWord2 | 文字(多個用逗號分隔) |
| title | 新聞標題 | Nvarchar(50) | 文字 | 不能為空 |
| author | 作者 | Nvarchar(20) | 文字 | 文字 |
| original | 原出處 | Nvarchar(20) | 文字 | 文字 |
| content | 新聞內容 | varChar(4000) | 文字 | 不能為空 |
<info>
<rec>
<depID>1</depID>
<smallClassID>20040212200856429814</smallClassID>
<type>1,3</type>
<keyWord>關鍵字1, 關鍵字2</keyWord>
<title>新聞標題</title>
<author>作者</author>
<original>原出處</original>
<content>新聞內容</content>
</rec>
</info>
將上述生成的字符串以 POST 方式發送至 https://服務器IP:端口/receiveInfo.ASP(務必使用 POST 傳送)。以下為經測試通過的完整代碼。
<%
set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
XMLstr = "<info><rec><depID>1</depID><smallClassID>20040212200856429814</smallClassID><type>1,3</type><keyWord>關鍵字1, 關鍵字2</keyWord><title>新聞標題</title><author>作者</author><original>原出處</original><content>新聞內容</content></rec></info>"
URL = "https://192.168.1.5:9020/receiveInfo.ASP"
XMLhttp.open "POST", URL, False
xmlhttp.send XMLstr
if err.number = 0 then
if XMLhttp.status <> "200" then
Response.Write "<font style='font-size:12px;color:red'>狀態:" & XMLhttp.status & " ;描述:" & XMLHttp.ResponseText & "</font>"
else
Response.Write "<font style='font-size:12px;color:red'> " & XMLHttp.ResponseText & "</font>"
end if
else
Response.Write "<font style='font-size:12px;color:red'>狀態:" & XMLhttp.status & " ;描述:" & XMLHttp.ResponseText & "</font>"
end if
%>
<%@codepage=936%>
<%
Server.ScriptTimeOut = 99999
Response.Buffer = false
Response.CharSet = "gb2312"
set xmldoc = Server.CreateObject("MSXML2.DOMDocument")
XMLdoc.load Request
set root = XMLdoc.DocumentElement
for i = 1 to XMLdoc.documentelement.childNodes.length
Set recnote = XMLdoc.documentelement.childNodes(i-1)
Set depIDnote = recnote.selectSingleNode("depID")
Set smallClassIDnote = recnote.selectSingleNode("smallClassID")
Set typenote = recnote.selectSingleNode("type")
Set keyWordnote = recnote.selectSingleNode("keyWord")
Set titlenote = recnote.selectSingleNode("title")
Set authornote = recnote.selectSingleNode("author")
Set originalnote = recnote.selectSingleNode("original")
Set contentnote = recnote.selectSingleNode("content")
response.Write depIDnote.text & "||"
response.Write smallClassIDnote.text & "||"
response.Write typenote.text & "||"
response.Write keyWordnote.text & "||"
response.Write titlenote.text & "||"
response.Write authornote.text & "||"
response.Write originalnote.text & "||"
response.Write contentnote.text & "||"
next
response.Write("0")
%>