admin管理员组

文章数量:1563235

定时自动请求就行了

import requests
import hashlib
import time

# 设置API的URL和路径
url = "https://desk.ctyun:8810/api/"
computer_connect = "desktop/client/connect"

# 设置连接云电脑时需要的设备信息
device_info = {
    "objId": "你自己的",
    "objType": 0,
    "osType": 15,
    "deviceId": 60,
    "deviceCode": "你自己的",
    "deviceName": "Edge浏览器",
    "sysVersion": "Windows NT 10.0; Win64; x64",
    "appVersion": "1.36.1",
    "hostName": "Edge浏览器",
    "vdCommand": "",
    "ipAddress": "",
    "macAddress": "",
    "hardwareFeatureCode": "你自己的"
}

# 配置请求头中需要的一些参数
app_model_value = "2"
device_code_value = "你自己的"
device_type_value = "60"
request_id_value = "1704522993726"
tenant_id_value = "250432"
timestamp_value = str(int(time.time() * 1000))
userid_value = "你自己的"
version_value = "201360101"
secret_key_value = "你自己的"

# 创建签名字符串
signature_str = device_type_value + request_id_value + tenant_id_value + timestamp_value + userid_value + version_value + secret_key_value

# 使用MD5算法创建签名
hash_obj = hashlib.md5()
hash_obj.update(signature_str.encode('utf-8'))
digest_hex = hash_obj.hexdigest().upper()

# 准备请求头
headers = {
    'ctg-appmodel': app_model_value,
    'ctg-devicecode': device_code_value,
    'ctg-devicetype': device_type_value,
    'ctg-requestid': request_id_value,
    'ctg-signaturestr': digest_hex,
    'ctg-tenantid': tenant_id_value,
    'ctg-timestamp': timestamp_value,
    'ctg-userid': userid_value,
    'ctg-version': version_value
}

# 发起POST请求连接云电脑
response = requests.post(url + computer_connect, data=device_info, headers=headers)

# 打印出云电脑的连接状态
print("云电脑连接状态:", response.json())

版,可以使用云函数

// 引入必要的模块
const axios = require('axios'); // 用于发起网络请求
const crypto = require('crypto'); // 用于加密
const qs = require('qs'); // 用于处理URL查询字符串

// 设置API的URL和路径
const url = "https://desk.ctyun:8810/api/"; // 云电脑服务的API地址
const computerConnect = "desktop/client/connect"; // 连接到云电脑的API路径

// 设置连接云电脑时需要的设备信息
let deviceInfo = {
  objId: "你自己的", // 对象ID,需要替换成用户自己的
  objType: 0, // 对象类型
  osType: 15, // 操作系统类型
  deviceId: 60, // 设备ID
  deviceCode: "你自己的", // 设备代码,需要替换成用户自己的
  deviceName: "Edge浏览器", // 设备名称
  sysVersion: "Windows NT 10.0; Win64; x64", // 系统版本
  appVersion: "1.36.1", // 应用版本
  hostName: "Edge浏览器", // 主机名
  vdCommand: "", // 虚拟设备指令
  ipAddress: "", // IP地址
  macAddress: "", // MAC地址
  hardwareFeatureCode: "你自己的" // 硬件特征码,需要替换成用户自己的
};

// 配置请求头中需要的一些参数
let appModelValue = "2"; // ctg-appmodel 应用模型值
let deviceCodeValue = "你自己的"; // ctg-devicecode 设备代码,需要替换成用户自己的
let deviceTypeValue = "60"; // ctg-devicetype 设备类型
let requestIdValue = "1704522993726"; // 请求ID
let tenantIdValue = "250432"; // 租户ID
let timestampValue = Date.now().toString(); // 时间戳
let useridValue = "你自己的"; // ctg-userid 用户ID,需要替换成用户自己的
let versionValue = "201360101"; // 版本值
let secretKeyValue = "你自己的"; // 密钥,需要替换成用户自己的

// 创建签名字符串
let signatureStr = deviceTypeValue + requestIdValue + tenantIdValue + timestampValue + useridValue + versionValue + secretKeyValue;

// 使用MD5算法创建签名
let hash = crypto.createHash('md5');
hash.update(signatureStr);
let digestHex = hash.digest('hex').toUpperCase();

// 发起POST请求连接云电脑
axios.post(url + computerConnect, qs.stringify(deviceInfo), {
  headers: {
    'ctg-appmodel': appModelValue,
    'ctg-devicecode': deviceCodeValue,
    'ctg-devicetype': deviceTypeValue,
    'ctg-requestid': requestIdValue,
    'ctg-signaturestr': digestHex,
    'ctg-tenantid': tenantIdValue,
    'ctg-timestamp': timestampValue,
    'ctg-userid': useridValue,
    'ctg-version': versionValue
  }
}).then((response) => {
  console.log("云电脑连接状态:", response.data); // 打印出云电脑的连接状态
}).catch((error) => {
  console.error(error); // 打印出错信息
});

本文标签: 天翼代码电脑Pythonnodejs