我创建了一个脚本来从网站获取 json 响应。为了得到响应,我必须发出 post http 请求以及适当的参数。脚本运行良好。
payload
我在脚本中使用的很长。它可能会更长。
现在,我的问题是,我怎样才能将这么长的一行分成多行?
这就是我尝试过的方式:
Sub GetJsonResponse()
Const URL = "https://api.pcexpress.ca/product-facade/v3/products/category/listing"
Dim payload$
payload = "{""pagination"":{""from"":2,""size"":48},""banner"":""loblaw"",""cartId"":""702da51e-a7ab-4f54-be5e-5bf38bd6d7a2"",""lang"":""en"",""date"":""09062021"",""storeId"":""1032"",""pcId"":null,""pickupType"":""STORE"",""enableSeldonIntegration"":true,""features"":[""loyaltyServiceIntegration"",""sunnyValeServiceIntegration""],""inventoryInfoRequired"":true,""sort"":{""topSeller"":""desc""},""categoryId"":""27985""}"
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", URL, False
.setRequestHeader "content-type", "application/json;charset=UTF-8"
.setRequestHeader "x-apikey", "1im1hL52q9xvta16GlSdYDsTsG0dmyhF"
.send (payload)
Debug.Print .responseText
End With
End Sub