后臺入口接口一般指的是您的系統管理頁面等登錄網址,比如http://test.com/xyadmin
接口的內容是固定的參考下文,其中latest是可以指定具體的版本號的。本頁面做了緩存,因為基本上很少需要更新這部分內容,緩存能加快用戶的訪問速度,提升瀏覽體驗。
### 實例
```
// 調用云后臺
Route::get('/xyadmin$', request()->url(true) . '/');
Route::get('/xyadmin/$', function (\think\Request $request, \think\Response $response) {
$seconds_to_cache = 86400 * 30;
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://admin.starideas.net/xyadmin/?version=latest); // 支持調用不同版本便于官方升級不影響老項目
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何證
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 表示不檢查證書
$xyadminIndex = curl_exec($ch);
curl_close($ch);
return $response
->data($xyadminIndex ? $xyadminIndex : '調用云后臺出錯')
->code(200)
->expires($ts)
->cacheControl("max-age=$seconds_to_cache")
->contentType('text/html');
});
```