import json
import requests
webhook_url =
post_data = # 见应用凭证
# 服务器托管网获取飞书租户访问令牌,用于调用飞书开放平台的其他API接口
# url:飞书开放平台的获取租户访问令牌的API接口地址
url= r"https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal/"
r = requests.post(url, data=post_data) # 向url发送POST请求,返回的响应被存储在变量r中
tat = r.json()["tenant_access_token"] # json:将响应内容从JSON格式转换为Python字典,获取租户访问令牌
print(r.json())
# 向webhook_url发送POST请求(HTTP请求主要有两种常用的方法:GET获取数据 和 POST提交数据)
# https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot
# headers 对应 curl命令 -H 包含 HTTP请求头信息;data 对应 -d 作为 POST请求的数据
'''
curl -X POST
-H "Content-Type: application/json"
-d '{"msg_type":"text","content":{"text":"request example"}}' https://open.feishu.cn/open-apis/bot/v2/hook/****
'''
text_value = "request example"
text服务器托管网_value = "敬畏上帝,感恩"
headers = {
'Content-Type': 'application/json'
}
payload_message = {
"msg_type": "text",
"content": {
"text": text_value
}
}
response = requests.request("POST", webhook_url, headers=headers, data=json.dumps(payload_message)) # json.dumps:转换为JSON格式
print(response.text)
payload_message = {
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": "项目更新通知",
"content": [
[{
"tag": "text",
"text": "项目有更新: "
},
{
"tag": "a",
"text": "请查看",
"href": "http://www.example.com/"
},
{
"tag": "at",
"user_id": "all"
}
]
]
}
}
}
}
response = requests.request("POST", webhook_url, headers=headers, data=json.dumps(payload_message)) # json.dumps:转换为JSON格式
print(response.text)
payload_message = {
"msg_type": "interactive",
"card": {
"elements": [{
"tag": "div",
"text": {
"content": "**西湖**,位于浙江省杭州市西湖区龙井路1号,杭州市区西部,景区总面积49平方千米,汇水面积为21.22平方千米,湖面面积为6.38平方千米。",
"tag": "lark_md"
}
}, {
"actions": [{
"tag": "button",
"text": {
"content": "更多景点介绍 :玫瑰:",
"tag": "lark_md"
},
"url": "https://www.example.com",
"type": "default",
"value": {}
}],
"tag": "action"
}],
"header": {
"title": {
"content": "今日旅游推荐",
"tag": "plain_text"
}
}
}
}
response = requests.request("POST", webhook_url, headers=headers, data=json.dumps(payload_message)) # json.dumps:转换为JSON格式
print(response.text)
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: df_test检查每个col1分类下col2是否会随col1的增大而减小
# 实验1 # df_test检查col1是否会随col0的增大而减小 df_test = pd.DataFrame( data=[ range(10), range(10)[::-1] ], index=[‘col’+str(i) for i in rang…