参数名称 | 描述 |
x-cmq-request-id | 此次推送消息的 requestId |
x-cmq-message-id | 此次推送消息的 msgId |
x-cmq-message-tag | 此次推送消息的消息标签 |
参数名称 | 类型 | 描述 |
TopicOwner | String | 被订阅的主题拥有者的 APPID |
topicName | String | 主题名称 |
subscriptionName | String | 订阅名称 |
msgId | String | 消息 ID |
msgBody | String | 消息正文 |
publishTime | Int | 消息的发布时间 |
http://test.com/cgi
。
JSON 格式:POST /cgi HTTP/1.1Host: test.comContent-Length: 761Content-Type: text/plainUser-Agent: Qcloud Notification Service Agentx-cmq-request-id: 2394928734x-cmq-message-id: 6942316962x-cmq-message-tag: a, b{"TopicOwner":100015036,"topicName":"MyTopic","subscriptionName":"mysubscription","msgId":"6942316962","msgBody":"test message","publishTime":11203432}
POST /cgi HTTP/1.1Host: test.comContent-Length: 123Content-Type: text/plainUser-Agent: Qcloud Notification Service Agentx-cmq-request-id: 2394928734x-cmq-message-id: 6942316962x-cmq-message-tag: a, btest message
#!/usr/bin/pythonfrom BaseHTTPServer import HTTPServer, BaseHTTPRequestHandlerimport jsonclass TestHTTPHandle(BaseHTTPRequestHandler):def do_POST(self):content_len = int(self.headers.getheader('content-length',0))post_body = self.rfile.read(content_len)print "receive cmq topic publisher request:"print self.headersprint post_bodypost_data = json.loads(post_body)for k,v in post_data.iteritems():print "key:%s value:%s" % (k,v)#response http status 200self.send_response(200)self.end_headers()self.wfile.write('ok')def start_server(port):http_server = HTTPServer(('0.0.0.0', int(port)),TestHTTPHandle)http_server.serve_forever()if __name__ == '__main__':start_server(80)
本页内容是否解决了您的问题?