feat: update

This commit is contained in:
eric
2023-05-22 14:00:50 +08:00
parent ba2822cbd0
commit ad1555e05d
4 changed files with 135 additions and 26 deletions

65
app.py
View File

@@ -217,34 +217,49 @@ async def getphonenum(
@app.post("/callback")
# def read_root():
# return {"Hello": "World"}
async def callback(item: Item):
time.sleep(10)
print("item", item)
async def callback(
# item: Item,
inputArguments: Union[str, None] = None,
appid: Union[str, None] = Header(default=None),
bid: Union[str, None] = Header(default=None),
requestid: Union[str, None] = Header(default=None),
uid: Union[str, None] = Header(default=None),
):
# time.sleep(10)
# print("item", item)
try:
inputArguments = unquote(inputArguments, "utf-8")
except:
inputArguments = ""
# 正则获取11位手机号
phonenumber = findPhoneNum(inputArguments)
print("phonenumber", phonenumber)
content = {
"ans_node_name": "小微闲聊",
"title": "小薇兄你好",
# "ans_node_name": "小微闲聊",
# "title": "小薇兄你好",
"answer": "你好呀123",
"answer_type": "text",
"bid_stat": {
"curr_time": "20190515-18:07:37",
"err_msg": "微信通用意图.肯定.branches.s_Any@.arguments's element.slot slot does not exist!",
"latest_time": "20190523-16:06:33",
"latest_valid": False,
"up_ret": -1,
},
"confidence": 1,
"from_user_name": "o9U-85tEZToQxIF8ht6o-KkagxO0",
"status": "FAQ",
"to_user_name": "xalsjfasf1ljasjdf1",
"options": [
{
"ans_node_id": 12355896,
"ans_node_name": "自建应用",
"answer": "有详情入口的应用消息一般是通过api进行推送的入口不E_BREAKLINE_BREAK2、企业号或企业微信后台推送的图文消息在微信PC侧会有“详情”入口在企业微信手机端、PC端以及微信手机端则不会有“详情”入口。LINE_BREAKLINE_BREAK注意微信电脑端侧仅会显示摘要和详情不显示标题。企业微信电脑端、微信微信手机端、企业微信手机端则会显示标题和摘要。若未填写摘要则不显示摘要。",
"confidence": 0.795230507850647,
"title": "自建应用消息没有详情入口",
}
],
# "bid_stat": {
# "curr_time": "20190515-18:07:37",
# "err_msg": "微信通用意图.肯定.branches.s_Any@.arguments's element.slot slot does not exist!",
# "latest_time": "20190523-16:06:33",
# "latest_valid": False,
# "up_ret": -1,
# },
# "confidence": 1,
# "from_user_name": "o9U-85tEZToQxIF8ht6o-KkagxO0",
# "status": "FAQ",
# "to_user_name": "xalsjfasf1ljasjdf1",
# "options": [
# {
# "ans_node_id": 12355896,
# "ans_node_name": "自建应用",
# "answer": "有详情入口的应用消息一般是通过api进行推送的入口不E_BREAKLINE_BREAK2、企业号或企业微信后台推送的图文消息在微信PC侧会有“详情”入口在企业微信手机端、PC端以及微信手机端则不会有“详情”入口。LINE_BREAKLINE_BREAK注意微信电脑端侧仅会显示摘要和详情不显示标题。企业微信电脑端、微信微信手机端、企业微信手机端则会显示标题和摘要。若未填写摘要则不显示摘要。",
# "confidence": 0.795230507850647,
# "title": "自建应用消息没有详情入口",
# }
# ],
}
headers = {"Content-Type": "application/json"}
return JSONResponse(content=content, headers=headers)

74
getCodeStatus.py Normal file
View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
# 导入对应产品模块的client models。
from tencentcloud.sms.v20210111 import sms_client, models
# 导入可选配置类
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
try:
# 必要步骤:
# 实例化一个认证对象入参需要传入腾讯云账户密钥对secretIdsecretKey。
# 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。
# 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
# 以免泄露密钥对危及你的财产安全。
# SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi
cred = credential.Credential("AKIDOaT6SZQ0JL7cqnTryoOhkW1FBqELAizz", "kDPKyMTJs99sKVP1NREkzxKQFo66pIUP")
# cred = credential.Credential(
# os.environ.get(""),
# os.environ.get("")
# )
# 实例化一个http选项可选的没有特殊需求可以跳过。
httpProfile = HttpProfile()
# 如果需要指定proxy访问接口可以按照如下方式初始化hp
# httpProfile = HttpProfile(proxy="http://用户名:密码@代理IP:代理端口")
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
# 非必要步骤:
# 实例化一个客户端配置对象,可以指定超时时间等配置
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
# 实例化要请求产品(以sms为例)的client对象
# 第二个参数是地域信息可以直接填写字符串ap-guangzhou支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8
client = sms_client.SmsClient(cred, "ap-beijing", clientProfile)
# 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数
# 你可以直接查询SDK源码确定SendSmsRequest有哪些属性可以设置
# 属性可能是基本类型,也可能引用了另一个数据结构
# 推荐使用IDE进行开发可以方便的跳转查阅各个接口和数据结构的文档说明
req = models.PullSmsSendStatusRequest()
# 基本类型的设置:
# SDK采用的是指针风格指定参数即使对于基本类型你也需要用指针来对参数赋值。
# SDK提供对基本类型的指针引用封装函数
# 帮助链接:
# 短信控制台: https://console.cloud.tencent.com/smsv2
# 腾讯云短信小助手: https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81
# 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId示例如1400006666
req.SmsSdkAppId = "1400808237"
# 拉取最大条数最多100条
req.Limit = 10
# req.Action = 'PullSmsSendStatusByPhoneNumber'
# req.Version = '2021-01-11'
# req.Region = 10
# req.LiRegionmit = 10
# req.PhoneNumber = '+8613243889782'
# 通过client对象调用PullSmsSendStatus方法发起请求。注意请求方法名与请求对象是对应的。
# 返回的resp是一个PullSmsSendStatusResponse类的实例与请求对象对应。
resp = client.PullSmsSendStatus(req)
# 输出json格式的字符串回包
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err)

20
getapiPost.py Normal file
View File

@@ -0,0 +1,20 @@
import requests
import time
headers = {'content-type': 'application/json',"X-TC-Action": 'PullSmsSendStatusByPhoneNumber'}
payload = {
"Action": "PullSmsSendStatusByPhoneNumber",
"Version": "2021-01-11",
"Region": "ap-beijing",
# "BeginTime":time.time(), #用户触发接口的时候
"BeginTime":1684724400, #用户触发接口的时候
"Timestamp":1684724400,
"Offset": 0,
"Limit": 1,
"PhoneNumber": "+8613243889782",
"SmsSdkAppId": "1400808237",
"EndTime": 1684724400
}
r = requests.post("https://sms.tencentcloudapi.com", headers=headers,data=payload)
print('rjson',r.json())

View File

@@ -64,7 +64,7 @@ try:
req.SignName = "异度世界公众号"
# 模板 ID: 必须填写已审核通过的模板 ID
# 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
req.TemplateId = "1795420"
req.TemplateId = "1795459"
# 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,,若无模板参数,则设置为空
req.TemplateParamSet = []
# 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]