MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    python发消息的http请求参数错误

    HTTP API和第三方SDK
    python message
    2
    6
    154
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wihn2021 last edited by

      这是我的代码

      import requests
      md = {'sessionKey':'XXXXXXX','target':711XXXXX96,'messageChain':[{'type':'Plain','text':'hello'},{'type':'Plain','text':'world'}]}
      headers = {'Content-Type': 'application/json'}
      r4 = requests.post('http://XXXXXXXXX/sendGroupMessage',data=json.dumps(md),headers=headers)
      

      结果是400,参数错误。我试了不把json转化成字符串,也发生了参数错误,请问我应该怎么做?

      E 1 Reply Last reply Reply Quote 0
      • W
        wihn2021 last edited by wihn2021

        md = {'sessionKey':'RxxxxxeLr','target':71xxxxx96,'messageChain':[{'type':'Plain','text':'hello'},{'type':'Plain','text':'world'}]}
        r4 = requests.post('http://xxxxxx/sendGroupMessage',json=md)

        这是现在的代码,然而还是【无效参数】

        1 Reply Last reply Reply Quote 0
        • E
          ExMikuPro 0 @wihn2021 last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • E
            ExMikuPro 0 last edited by

            试试这个发送函数
            截屏2022-05-19 上午8.11.34.png
            msg是这个
            截屏2022-05-19 上午8.14.44.png

            W 1 Reply Last reply Reply Quote 0
            • W
              wihn2021 @ExMikuPro 0 last edited by

              @ExMikuPro-0 看上去和我第一次贴的代码没区别啊,都是json转为str传入data。我后来回退了MAH的版本就解决了

              1 Reply Last reply Reply Quote 1
              • E
                ExMikuPro 0 last edited by

                解决了就好🤣

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact