live2d_api/switch/index.php

18 lines
577 B
PHP
Raw Normal View History

2018-03-03 01:39:22 +08:00
<?php
isset($_GET['id']) ? $modelId = (int)$_GET['id'] : exit('error');
require '../tools/modelList.php';
$modelList = new modelList();
$modelList = $modelList->get_list();
$modelSwitchId = $modelId + 1;
if (!isset($modelList['models'][$modelSwitchId-1])) $modelSwitchId = 1;
header("Content-type: application/json");
echo json_encode(array('model' => array(
'id' => $modelSwitchId,
'name' => $modelList['models'][$modelSwitchId-1],
'message' => $modelList['messages'][$modelSwitchId-1]
)), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);