<?php
/**
 * 工作手机SDK使用示例
 */

require_once 'WorkPhoneClient.php';

use Cunkebao\WorkPhone\WorkPhoneClient;

// 初始化SDK
$sdk = new WorkPhoneClient(
    'http://localhost:8899',
    'workphone-secret-key-2026'
);

echo "=== 工作手机SDK v3.0 示例 ===\n\n";

// 1. 获取设备列表
echo "1. 获取设备列表\n";
$devices = $sdk->getDevices();
print_r($devices);
echo "\n";

// 2. 获取在线设备
echo "2. 获取在线设备\n";
$onlineDevices = $sdk->getOnlineDevices();
if (empty($onlineDevices)) {
    echo "   暂无在线设备\n";
} else {
    foreach ($onlineDevices as $device) {
        echo "   - {$device['device_id']}: {$device['model']}\n";
    }
}
echo "\n";

// 3. 发送消息示例（需要有在线设备）
if (!empty($onlineDevices)) {
    $deviceId = array_key_first($onlineDevices);
    
    echo "3. 发送微信消息\n";
    $result = $sdk->sendMessage($deviceId, 'wechat', '测试联系人', '你好，这是测试消息');
    print_r($result);
    echo "\n";
    
    echo "4. 执行AI任务\n";
    $result = $sdk->executeTask($deviceId, '打开微信查看最新消息');
    print_r($result);
    echo "\n";
}

echo "=== 示例结束 ===\n";
