MiraiForum

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

    如何从零开始搭建一个 mirai-api-http 2.0 的 python 框架?(大雾

    HTTP API和第三方SDK
    3
    12
    719
    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.
    • S
      shenjackyuanjie last edited by

      主要目的是求助
      (我真没看懂http请求的写法,用的是2.0 RC2

      1 Reply Last reply Reply Quote 0
      • S
        shenjackyuanjie last edited by

        所以哪位帮我讲一下
        http 2.0的http请求?(

        1 Reply Last reply Reply Quote 0
        • Samarium150
          Samarium150 ⭐2021⭐ last edited by

          有社区Python SDK的情况下为什么还要自己搭呢

          import requests
          
          host = "localhost:9999"
          
          # Authorization
          r = request.post("{}/auth".format(host))
          print(r)
          
          S 1 Reply Last reply Reply Quote 0
          • ryoii
            ryoii 梦中的鸡翅 last edited by

            使用文档在 dev2.0 分支下 https://github.com/project-mirai/mirai-api-http/tree/dev-2.0

            http adapter 的文档也在这里,按照url和参数列表去构建请求就好了 https://github.com/project-mirai/mirai-api-http/blob/dev-2.0/docs/adapter/HttpAdatper.md

            使用流程基本就是: verify -> bind -> use

            S 1 Reply Last reply Reply Quote 0
            • S
              shenjackyuanjie @ryoii last edited by

              @ryoii
              emmmm
              http adapter的请求方法是用socket还是urllib .openurl?
              还是urllib.Request?
              请求格式呢?(
              主要是data和header都尝试过了(

              1 Reply Last reply Reply Quote 0
              • S
                shenjackyuanjie last edited by

                fd7a4377-37df-4a5a-aed7-30d32755dd67-image.png
                这个玩意比较离谱(

                adapters: 
                  - http
                debug: false
                enableVerify: true
                verifyKey: 45620725
                singleMode: false
                cacheSize: 4096
                adapterSettings: 
                  http:
                    host: 127.0.0.10
                    port: 10000
                    cors: [*]
                  ws:
                    host: 127.0.0.11
                    port: 10000
                    reservedSyncId: -1
                
                1 Reply Last reply Reply Quote 0
                • S
                  shenjackyuanjie @Samarium150 last edited by

                  @samarium150
                  也不对欸,试过了,返回400
                  错误参数d8719eea-1362-4527-b4a2-e7d51acdeec8-image.png

                  S 2 Replies Last reply Reply Quote 0
                  • S
                    shenjackyuanjie @shenjackyuanjie last edited by

                    2c13e14d-df90-44a7-b8e2-3334461715c3-image.png
                    EMMMM
                    似乎第一步我的请求没问题
                    但是他就是返回“错误参数”

                    1 Reply Last reply Reply Quote 0
                    • S
                      shenjackyuanjie @shenjackyuanjie last edited by

                      @shenjackyuanjie 淦!
                      才发现verfiy写了两遍

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        shenjackyuanjie @shenjackyuanjie last edited by

                        67b66c1f-83f9-4c86-b9c4-aac4b2e1d87d-image.png
                        无言以对

                        1 Reply Last reply Reply Quote 0
                        • S
                          shenjackyuanjie last edited by

                          没事了
                          需要用json而不是data(

                          1 Reply Last reply Reply Quote 0
                          • ryoii
                            ryoii 梦中的鸡翅 last edited by

                            XD

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