我正在做以下事情:
......
....
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use('/public', express.static(__dirname + '/public'));
app.post('/uninstalled', function (req, res, next)
{
var bodyAsQueryString = queryString.stringify(req.body);
console.log('bodyAsQueryString = ' + bodyAsQueryString);
var hmacReceived = req.headers['x-shopify-hmac-sha256'];
var calculatedHmac = crypto.createHmac('SHA256', config.app.secret);
req.on("data", function(data)
{
console.log('on data...');
calculatedHmac.update(data);
});
req.on("end", function()
{
console.log('on end...');
calculatedHmac = calculatedHmac.digest("base64");
console.log('hmacReceived = ' + hmacReceived);
console.log('calculatedHmac = ' + calculatedHmac);
});
req.on("error", function(err)
{
console.log('on error...');
console.log(err);
return next(err);
});
});
以上req.on("...")
都没有调用过(没有控制台记录......) - 我做错了什么?
bodyAsQueryString
的价值总是如下(我用xxxxx
替换了个人数据):
ID = XXXXX&安培;名称= XXXXX&安培;电子邮件= XXXXXX&安培;域= XXXXXXX&安培; created_at = 2015-03-21T00%3A31%3A36%2B00%3A00&安培;省=安培;国家= GB&安培;地址1 = XXXXXXXXX&安培;拉链= E59JY&安培;城市=伦敦和放大器;源= XXXX和放大器;电话= XXXXXX和放大器;的updated_at = 2015-08-19T15%3A12%3A31%2B01%3A00和放大器; CUSTOMER_EMAIL =安培;纬度= XXXXX&放大器;经度= -xxxxxx和放大器; primary_location_id =安培; primary_locale = EN&安培; COUNTRY_CODE = GB&安培; COUNTRY_NAME =美国%20Kingdom&安培;货币= USD&安培;时区=(GMT%2B00%3A00)%20Europe%2FLondon&安培; iana_timezone =欧洲%2FLondon&安培; shop_owner = XXXXXX&安培; money_format =%24%20%7B%7Bamount%7D %7D&安培; money_with_currency_format =%24%20%7B%7Bamount%7D%7D%20USD&安培; PROVINCE_CODE =安培; taxes_included =假安培; tax_shipping =安培; county_taxes =真安培; plan_display_name =联盟&安培; PLAN_NAME =联盟&安培; myshopify_domain = xxxxxx.myshopify。 COM&安培; google_apps_domain =安培; google_apps_login_enabled =安培; money_in_emails_format =%24%7B%7Bamount%7D%7D&安培; money_with_currency_in_emails_format =%24%7B%7Bam 'mount%7D%7D%20USD&安培; eligible_for_payments =假安培; requires_extra_payments_agreement =假安培; password_enabled =真安培; has_storefront =真安培; setup_required =假
答案 0 :(得分:1)
您需要使用原始POST主体而不是req.body。
尝试这样的事情:
Option Explicit
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
Sub Routine()
Dim IE as Object
Set IE = GetIE
With IE
.Visible = True
.Navigate "https://myURL/Default.aspx"
IEWait
Dim oDoc as Object, sLink as String
Set oDoc = .document
sLInk = "in_1191_1"
IECLickLink oDoc, sLink
End Sub
Sub IEClickLink(doc As Object, sLink As String)
'assumes IE is loaded as InternetExplorer.Application") with URL loaded
'assumes doc is declared as IE.document
With doc
Dim oLink As Object
For Each oLink In .Links
If InStr(1, oLink.href, sLink) Then 'looks for particular text in href attribute then clicks that particular link
oLink.Click
Exit For
End If
Next
End With
End Sub
Function GetIE() As Object
On Error Resume Next
Set GetIE = CreateObject("InternetExplorer.Application")
End Function
Sub IEWait()
'assumes IE is loaded as InternetExplorer.Application
With IE
Do While .Busy Or .ReadyState <> 4: Sleep (100): Loop
End With
End Sub
这个类似问题的进一步细节:
答案 1 :(得分:0)
结束了它,因为我没有在回调中的任何地方回复客户,例如:
res.sendStatus(200); or res.sendStatus(500); etc...
这很奇怪,因为我的回调中的代码执行得很好(即使没有回复客户端)但显然
如果节点解析器意识到存在req.on()
并且没有回复客户端,无论是在客户端内部还是外部,它都会忽略req.on(..)
,这实际上没有意义......要么整个事情要破坏如果缺少对客户的回复,则不予处理。