收藏
回答

服务号关注和取消关注进行回调的时候 body是空,那关注事件应该怎么拿到呢?

"body": {},
    "client": {
        "_closeAfterHandlingError": false,
        "_events": {
            "close": [
                null,
                null,
                null
            ],
            "end": [
                null,
                null
            ],
            "error": [
                null,
                null
            ]
        },
        "_eventsCount": 8,
        "_hadError": false,
        "_host": null,
        "_httpMessage": {
            "_closed": false,
            "_contentLength": null,
            "_defaultKeepAlive": true,
            "_events": {
                "finish": [
                    null,
                    null
                ]
            },
            "_eventsCount": 4,
            "_expect_continue": false,
            "_hasBody": true,
            "_header": null,
            "_headerSent": false,
            "_keepAliveTimeout": 5000,
            "_last": false,
            "_maxRequestsPerSocket": 0,
            "_removedConnection": false,
            "_removedContLen": false,
            "_removedTE": false,
            "_sent100": false,
            "_trailer": "",
            "chunkedEncoding": false,
            "destroyed": false,
            "finished": false,
            "locals": {},
            "maxRequestsOnConnectionReached": false,
            "outputData": [],
            "outputSize": 0,
            "req": {
                "_consuming": false,
                "_dumped": false,
                "_events": {},
                "_parsedUrl": {
                    "_raw": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "auth": null,
                    "hash": null,
                    "host": null,
                    "hostname": null,
                    "href": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "path": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "pathname": "/wechat/event-callback",
                    "port": null,
                    "protocol": null,
                    "query": "signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "search": "?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "slashes": null
                },
                "_readableState": {
                    "awaitDrainWriters": null,
                    "buffer": [],
                    "bufferIndex": 0,
                    "highWaterMark": 65536,
                    "length": 0,
                    "pipes": []
                },
                "_remoteAddress": "172.19.0.1",
                "_startAt": [
                    5233992,
                    915493621
                ],
                "_startTime": "2025-12-24T15:10:31.894Z",
                "aborted": false,
                "baseUrl": "/api",
                "body": {},
                "client": "[Circular]",
                "complete": false,
                "cookies": {},
                "httpVersion": "1.1",
                "httpVersionMajor": 1,
                "httpVersionMinor": 1,
                "joinDuplicateHeaders": null,
                "method": "POST",
                "originalUrl": "/api/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                "params": {},
                "query": {
                    "nonce": "585873633",
                    "openid": "oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "signature": "e90cde1009495469c04e1a6d963da65b7db9cb15",
                    "timestamp": "1766589031"
                },
                "rawTrailers": [],
                "res": "[Circular]",
                "route": {
                    "methods": {
                        "post": true
                    },
                    "path": "/wechat/event-callback",
                    "stack": [
                        {
                            "keys": [],
                            "method": "post",
                            "name": "<anonymous>",
                            "regexp": {
                                "fast_slash": false,
                                "fast_star": false
                            }
                        }
                    ]
                },
                "signedCookies": {},
                "socket": "[Circular]",
                "statusCode": null,
                "statusMessage": null,
                "upgrade": false,
                "url": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ"
            },
            "sendDate": true,
            "shouldKeepAlive": true,
            "strictContentLength": false,
            "useChunkedEncodingByDefault": true,
            "writable": true
        },
        "_parent": null,
        "_paused": false,
        "_peername": {
            "address": "172.19.0.1",
            "family": "IPv4",
            "port": 59918
        },
        "_pendingData": null,
        "_pendingEncoding": "",
        "_readableState": {
            "awaitDrainWriters": null,
            "buffer": [],
            "bufferIndex": 0,
            "highWaterMark": 65536,
            "length": 0,
            "pipes": []
        },
        "_server": {
            "_connectionKey": "4:0.0.0.0:8080",
            "_connections": 1,
            "_events": {},
            "_eventsCount": 4,
            "_handle": {
                "reading": false
            },
            "_listeningId": 2,
            "_unref": false,
            "_usingWorkers": false,
            "_workers": [],
            "allowHalfOpen": true,
            "connectionsCheckingInterval": 30000,
            "headersTimeout": 60000,
            "highWaterMark": 65536,
            "httpAllowHalfOpen": false,
            "keepAlive": false,
            "keepAliveInitialDelay": 0,
            "keepAliveTimeout": 5000,
            "keepAliveTimeoutBuffer": 1000,
            "maxHeadersCount": null,
            "maxRequestsPerSocket": 0,
            "noDelay": true,
            "pauseOnConnect": false,
            "rejectNonStandardBodyWrites": false,
            "requestTimeout": 300000,
            "requireHostHeader": true,
            "timeout": 0
        },
        "_sockname": null,
        "_writableState": {
            "bufferedIndex": 0,
            "corked": 0,
            "highWaterMark": 65536,
            "length": 0,
            "pendingcb": 0,
            "writelen": 0
        },
        "allowHalfOpen": true,
        "connecting": false,
        "parser": {
            "0": null,
            "_consumed": true,
            "_headers": [],
            "_url": "",
            "incoming": {
                "_consuming": false,
                "_dumped": false,
                "_events": {},
                "_parsedUrl": {
                    "_raw": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "auth": null,
                    "hash": null,
                    "host": null,
                    "hostname": null,
                    "href": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "path": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "pathname": "/wechat/event-callback",
                    "port": null,
                    "protocol": null,
                    "query": "signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "search": "?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "slashes": null
                },
                "_readableState": {
                    "awaitDrainWriters": null,
                    "buffer": [],
                    "bufferIndex": 0,
                    "highWaterMark": 65536,
                    "length": 0,
                    "pipes": []
                },
                "_remoteAddress": "172.19.0.1",
                "_startAt": [
                    5233992,
                    915493621
                ],
                "_startTime": "2025-12-24T15:10:31.894Z",
                "aborted": false,
                "baseUrl": "/api",
                "body": {},
                "client": "[Circular]",
                "complete": false,
                "cookies": {},
                "httpVersion": "1.1",
                "httpVersionMajor": 1,
                "httpVersionMinor": 1,
                "joinDuplicateHeaders": null,
                "method": "POST",
                "originalUrl": "/api/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                "params": {},
                "query": {
                    "nonce": "585873633",
                    "openid": "oqHva2G-gmWcqwaX7_UyssiYk6TQ",
                    "signature": "e90cde1009495469c04e1a6d963da65b7db9cb15",
                    "timestamp": "1766589031"
                },
                "rawTrailers": [],
                "res": {
                    "_closed": false,
                    "_contentLength": null,
                    "_defaultKeepAlive": true,
                    "_events": {
                        "finish": [
                            null,
                            null
                        ]
                    },
                    "_eventsCount": 4,
                    "_expect_continue": false,
                    "_hasBody": true,
                    "_header": null,
                    "_headerSent": false,
                    "_keepAliveTimeout": 5000,
                    "_last": false,
                    "_maxRequestsPerSocket": 0,
                    "_removedConnection": false,
                    "_removedContLen": false,
                    "_removedTE": false,
                    "_sent100": false,
                    "_trailer": "",
                    "chunkedEncoding": false,
                    "destroyed": false,
                    "finished": false,
                    "locals": {},
                    "maxRequestsOnConnectionReached": false,
                    "outputData": [],
                    "outputSize": 0,
                    "req": "[Circular]",
                    "sendDate": true,
                    "shouldKeepAlive": true,
                    "strictContentLength": false,
                    "useChunkedEncodingByDefault": true,
                    "writable": true
                },
                "route": {
                    "methods": {
                        "post": true
                    },
                    "path": "/wechat/event-callback",
                    "stack": [
                        {
                            "keys": [],
                            "method": "post",
                            "name": "<anonymous>",
                            "regexp": {
                                "fast_slash": false,
                                "fast_star": false
                            }
                        }
                    ]
                },
                "signedCookies": {},
                "socket": "[Circular]",
                "statusCode": null,
                "statusMessage": null,
                "upgrade": false,
                "url": "/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ"
            },
            "joinDuplicateHeaders": null,
            "maxHeaderPairs": 2000,
            "outgoing": null,
            "socket": "[Circular]"
        },
        "server": {
            "_connectionKey": "4:0.0.0.0:8080",
            "_connections": 1,
            "_events": {},
            "_eventsCount": 4,
            "_handle": {
                "reading": false
            },
            "_listeningId": 2,
            "_unref": false,
            "_usingWorkers": false,
            "_workers": [],
            "allowHalfOpen": true,
            "connectionsCheckingInterval": 30000,
            "headersTimeout": 60000,
            "highWaterMark": 65536,
            "httpAllowHalfOpen": false,
            "keepAlive": false,
            "keepAliveInitialDelay": 0,
            "keepAliveTimeout": 5000,
            "keepAliveTimeoutBuffer": 1000,
            "maxHeadersCount": null,
            "maxRequestsPerSocket": 0,
            "noDelay": true,
            "pauseOnConnect": false,
            "rejectNonStandardBodyWrites": false,
            "requestTimeout": 300000,
            "requireHostHeader": true,
            "timeout": 0
        }
    },
    "complete": false,
    "cookies": {},
    "httpVersion": "1.1",
    "httpVersionMajor": 1,
    "httpVersionMinor": 1,
    "joinDuplicateHeaders": null,
    "level": "info",
    "message": "收到微信事件回调XML数据req:",
    "method": "POST",
    "originalUrl": "/api/wechat/event-callback?signature=e90cde1009495469c04e1a6d963da65b7db9cb15&timestamp=1766589031&nonce=585873633&openid=oqHva2G-gmWcqwaX7_UyssiYk6TQ",
    "params": {},
回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2025-12-25

    nodejs啊,得安装xml插件,要不然获取不到xml

    2025-12-25
    有用
    回复
登录 后发表内容