forked from Lesin/reposync
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
import requests
|
||
|
||
|
||
# 你的GitHub用户名(或用于认证的token)
|
||
# 注意:出于安全考虑,通常不建议在代码中硬编码密码,而是使用token
|
||
|
||
# 你的仓库信息
|
||
|
||
|
||
|
||
# GitHub创建issue的API URL
|
||
url = f"https://api.github.com/repos/fuxingtamu/yundingzhiyi/pulls"
|
||
|
||
# 构造请求头
|
||
token = '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'
|
||
# 构造请求头
|
||
headers = {
|
||
'Authorization': f'token {token}',
|
||
'Accept': 'application/vnd.github+json'
|
||
}
|
||
|
||
# 发送POST请求
|
||
data = {
|
||
|
||
}
|
||
|
||
response = requests.get(url, headers=headers, json=data,verify=False)
|
||
# 打印响应
|
||
#print(response.text)
|
||
pr_info = response.json()
|
||
for pr in pr_info:
|
||
print(pr['title'])
|
||
print(pr['state'])
|
||
print(pr['body'])
|
||
print(pr['number'])
|
||
print(pr['base']['ref'])
|
||
print(pr['head']['ref'])
|
||
|
||
# 检查响应状态码
|
||
if response.status_code == 200:
|
||
# 注意:这里假设响应体中包含一个'number'字段作为issue的ID,但实际上GitHub可能返回不同的结构
|
||
# 你需要根据实际的响应结构来调整以下代码
|
||
issue_info = response.json()
|
||
print(f'Issue created with ID: {issue_info["number"]}')
|
||
else:
|
||
print(f"创建issue失败,状态码:{response.status_code},错误信息:{response.text}") |