API 通话中的会话 ID 未刷新

Session ID not refreshing in API call

我正在尝试使用 VBA Excel 访问网站 www.myfxbook.com. The API documentation is here(https://www.myfxbook.com/fr/api 提供的 API。获取数据的步骤如下:

  1. 通过登录API
  2. 登录
  3. 从登录的响应中获取会话的会话 ID API
  4. 根据这个Session ID通过各种其他API获取数据
  5. 通过注销注销API生成新会话

我面临的问题是,即使正在使用登录和注销 API 并且没有抛出错误,但当我尝试通过 [=] 使用它时,我总是得到相同的会话 ID 34=] VBA。另一方面,通过 Python 甚至浏览器使用相同的 URL 每次都会给我不同的会话 ID。我只能为这个项目使用 Excel。有人可以帮我如何在成功注销时获得不同的会话 ID 吗?

我正在使用下面的代码来执行此操作。为了安全起见,我隐藏了 (*******) 电子邮件 ID 和密码。

Sub extract()

Dim sht1 As Worksheet
Dim email As String
Dim password As String
Dim accountName As String
Dim url As String
Dim hreq As Object
Set hreq = CreateObject("MSXML2.XMLHTTP")
Dim accountID As String

Set sht1 = Sheets(1)
email = "*******"
password = "********"
accountName = "all day multiple currency coinexx"
loginURL = "https://www.myfxbook.com/api/login.xml?email=" + email + "&password=" + password
hreq.Open "GET", loginURL, False
hreq.Send
Dim xmlDoc As New MSXML2.DOMDocument60
Dim response As String
response = hreq.ResponseText
If Not xmlDoc.LoadXML(response) Then
    MsgBox ("Load Error")
End If

Dim xnodelist As MSXML2.IXMLDOMNodeList
Set xnodelist = xmlDoc.getElementsByTagName("session")
Dim sessionID As String
sessionID = xnodelist(0).Text

'Do Something here to get data. This part is working fine.

logoutURL = "https://www.myfxbook.com/api/logout.xml?session=" + sessionID
hreq.Open "GET", logoutURL, False
hreq.Send
response = hreq.ResponseText
If Not xmlDoc.LoadXML(response) Then
    MsgBox ("Load Error")
End If

End Sub

我认为您可能正在使用缓存。尝试通过额外的 header

强制避免这种情况
hreq.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"