最近更新时间:2021-06-18 10:15:48
从GitHub上获取SDK并安装
```
git clone https://github.com/KscSDK/ksc-sdk-python.git
cd ksc-sdk-python
python setup.py install
```
```
pip install ksc-sdk-python
```
-1.所在位置: '/etc/kscore.cfg' 或 './.kscore.cfg'
-2.注意: 使用相对路径时,需与运行目录保持一致
-3.ks_access_key_id和ks_secret_access_key是金山云控制台身份与管理里面生成密钥对(如有问题请联系商务或者技术支持)
```
[Credentials]
ks_access_key_id='xxxxxxxxxxxxxxxxxxxx'
ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxx'
```
```
from kscore.kls import getKlsClient
// 若使用文件配置过秘钥请使用这种方式:
client = getKetClient("kls", "cn‐beijing‐6",use_ssl=False)
//参数说明:
service_name: 服务名,填写"kls"
region_name: 区域名,填写"cn‐beijing‐6"
use_ssl: 是否https访问,填写False
// 若准备使用代码中配置秘钥,请使用这种方式:
ks_access_key_id='xxxxxxxxxxxxxxxxxxxx'
ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxx'
//参数:服务service_name,大区region_name
client = getKetClient("kls", "cn-beijing-6",use_ssl=False,ks_access_key_id=ks_access_key_id,ks_secret_access_key=ks_secret_access_key)
```
注:为了更方便您调用SDK,我们准备了实际的SDK调用示例,详见SDK调用示例
// Post 方法的调用均使用与下面示例相同的方式
// 文档中仅以禁止单路直播流推送的接口为例*
// 调用示例
```
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from kscore.kls import getKlsClient
import json
if __name__ == "__main__":
#ks_access_key_id='xxxxxxxxxxxxxxxxxxxxxxxxxx'
#ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxxxxx'
client = getKlsClient("kls", "cn-beijing-6",use_ssl=False,ks_access_key_id=ks_access_key_id,ks_secret_access_key=ks_secret_access_key)
param = {
"UniqueName" : "YOUR UNIQUENAME",
"App" : "YOUR APP",
"Pubdomain" : "YOUR PUBLISH DOMAIN",
"Stream" : "YOUR STREAM NAME",
"ForbidTillUnixTime" : -1
}
#禁止单路直播流推送 : ForbidStream
res = client.ForbidStream(param)
print json.dumps(res)
```
// Get 方法的调用均使用与下面示例相同的方式
// 文档中仅以查询录像任务状态的接口为例
// 调用示例
```
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from kscore.kls import getKlsClient
import json
if __name__ == "__main__":
#ks_access_key_id='xxxxxxxxxxxxxxxxxxxxxxxxxx'
#ks_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxxxxx'
client = getKlsClient("kls", "cn-beijing-6",use_ssl=False,ks_access_key_id=ks_access_key_id,ks_secret_access_key=ks_secret_access_key)
#查询录像任务状态接口(GetRecordTask)
res = client.GetRecordTask(RecID = 2017)
print json.dumps(res)
```
纯净模式