SmsV3HttpChannel 0.1
Python异步提交短信的模块
Requires Python: >=3

#### 1、SmsHttpChannel介绍

​       SmsHttpChannel模块是用于异步短信接口的发送，主要依赖于Tornado框架中的AsyncHTTPClient模块。

#### 2、接口所属哪家公司

​		主要用于**无锡线上线下通讯信息技术股份有限公司**的短信接口

#### 3、短信接口协议文档

​		v3 : http://doc.wxxsxx.com/

#### 4、代码示例

4.1、单内容多号码批量发送

```python
import logging
from typing import Dict
from xsxx.xsxx_channel import SmsV3HttpChannel

def submit_callback(response: Dict):
    """
        定义提交短信后的回调的处理函数
    :param response:
    :return:
    """
    logging.info(response)

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    logger = logging.getLogger(__name__)

    url = 'https://ip:port'
    userId = 'xxxx'
    password = 'xxxxx'

    http_channel = SmsV3HttpChannel(url=url, userId=userId, password=password)
    request_list = list()
    request_list.append(http_channel.one_content_phones(content='【线上线下】你的验证码:8888', mobile='1314342139x'))
    request_list.append(http_channel.one_content_phones(content='【线上线下】你的验证码:8888', mobile='1314342139x'))
    request_list.append(http_channel.one_content_phones(content='【线上线下】你的验证码:8888', mobile='1314342139x'))
    http_channel.send_request(http_channel, request_list, callback_func=submit_callback)

    """
    输出的结果:
        2020-11-26 23:26:16,812 - root - INFO - {'status': 0, 'msgid': '-4801649735315642901'}
        2020-11-26 23:26:16,829 - root - INFO - {'status': 0, 'msgid': '-4801649735315642900'}
        2020-11-26 23:26:16,861 - root - INFO - {'status': 0, 'msgid': '-4801649735315642899'}
    """
```

4.2、多内容打包发送

```python
import logging
from typing import Dict
from xsxx.xsxx_channel import SmsV3HttpChannel

def submit_callback(response: Dict):
    """
        定义提交短信后的回调的处理函数
    :param response:
    :return:
    """
    logging.info(response)

if __name__ == '__main__':

    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    logger = logging.getLogger(__name__)

    url = 'https://ip:port'
    userId = 'xxxx'
    password = 'xxxxx'

    http_channel = SmsV3HttpChannel(url=url, userId=userId, password=password)
    request_list = list()
    contentArr = list()
    contentArr.append(http_channel.content_arr_handler('【线上线下】你的验证码:8888', mobile='1314342139x'))
    contentArr.append(http_channel.content_arr_handler('【线上线下】你的验证码:8888', mobile='1314342139x'))
    contentArr.append(http_channel.content_arr_handler('【线上线下】你的验证码:8888', mobile='1314342139x'))
    request_list.append(http_channel.contents_phones(contentArr))
    http_channel.send_request(http_channel, request_list, callback_func=submit_callback)

    """
    输出的结果:
        2020-11-26 23:29:21,358 - root - INFO - {'result': [{'msgid': '-4801595859245881874', 'status': '0'}, {'msgid': '-4801595859245881873', 'status': '0'}, {'msgid': '-4801595859245881872', 'status': '0'}], 'status': '0'}
    """
```

4.3、查询余额

```python
import logging
from typing import Dict
from xsxx.xsxx_channel import SmsV3HttpChannel

def balance_callback(response: Dict):
    """
        查询余额请求后的回调的处理函数
    :param response:
    :return:
    """
    logging.info(response)

if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    logger = logging.getLogger(__name__)

    url = 'https://ip:port'
    userId = 'xxxx'
    password = 'xxxxx'

    http_channel = SmsV3HttpChannel(url=url, userId=userId, password=password)
    request_list = list()
    request_list.append(http_channel.get_user_balance())
    http_channel.send_request(http_channel, request_list, callback_func=balance_callback)
```

4.4、查询上行内容

```python
import logging
from typing import Dict
from xsxx.xsxx_channel import SmsV3HttpChannel

def mo_callback(response: Dict):
    """
        查询上行请求后的回调的处理函数
    :param response:
    :return:
    """
    logging.info(response)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    logger = logging.getLogger(__name__)

    url = 'https://ip:port'
    userId = 'xxxx'
    password = 'xxxxx'

    http_channel = SmsV3HttpChannel(url=url, userId=userId, password=password)
    request_list = list()
    request_list.append(http_channel.get_mo())
    http_channel.send_request(http_channel, request_list, callback_func=mo_callback)

    """
    输出的结果:
        2020-11-26 23:55:27,590 - root - INFO - {'status': 0, 'result': []}
    """
```

4.5、查询状态报告

```python
import logging
from typing import Dict
from xsxx.xsxx_channel import SmsV3HttpChannel

def report_callback(response: Dict):
    """
        定义状态请求后的回调的处理函数
    :param response:
    :return:
    """
    logging.info(response)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    logger = logging.getLogger(__name__)

    url = 'https://ip:port'
    userId = 'xxxx'
    password = 'xxxxx'

    http_channel = SmsV3HttpChannel(url=url, userId=userId, password=password)
    request_list = list()
    request_list.append(http_channel.get_report())
    http_channel.send_request(http_channel, request_list, callback_func=report_callback)

    """
    输出的结果:
        2020-11-26 23:57:14,371 - root - INFO - {'status': 0, 'result': []}
    """
```