安装模块
pip install qiniu
-
# -*- coding: utf-8 -*-
-
from qiniu import QiniuMacAuth
-
import requests, json
-
#填写七牛账户的aksk
-
access_key = "xx"
-
secret_key = "OO"
-
def get_qvm():
-
q = QiniuMacAuth(access_key, secret_key)
-
traffic_url = ''
-
json2 = {
-
"region_id": "cn-beijing", #地域
-
"page":"1",
-
"size":"100" #计费单位Hour, Month, Year
-
}
-
# 按照七牛凭证管理格式进行填充
-
acc_tock = q.token_of_request("GET", "api-qvm.qiniu.com",traffic_url,"X-Qiniu-Regionid: cn-beijing\n",content_type="application/json",body=json.dumps(json2))
-
acc_tocken = 'Qiniu ' + acc_tock
-
print(acc_tocken)
-
acc_headers = {'Host': 'api-qvm.qiniu.com', 'Content-Type': 'application/json', 'Authorization': acc_tocken,'X-Qiniu-Regionid': 'cn-beijing'}
-
r = requests.get(traffic_url, headers=acc_headers, data=json.dumps(json2))
-
print(r.text)
-
get_qvm()
云主机操作API:developer.qiniu.com/qvm/5567/openapi-overview
阅读(1163) | 评论(0) | 转发(0) |