game2006api/webapp/controller/RestApiController.class.php
aozhiwei a537ad0b2e 1
2023-07-21 19:08:41 +08:00

41 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class RestApiController extends BaseController {
public function dispatch()
{
//REQUEST_URI /api/nft/$netId/$nftType/$tokenId
$requestUri = $_SERVER['REQUEST_URI'];
if (!empty($requestUri)) {
$idx = strpos($requestUri, '/api/nft/');
if ($idx == 0) {
$tmpStrs = explode('?', $requestUri);
$requestUri = count($tmpStrs) > 0 ? $tmpStrs[0] : '';
$this->nftInfo(explode('/', $requestUri));
}
}
}
/*
https://game2006api.cebggame.com/api/nft/$netId/$nftType/$tokenId
$netId: 链id(网络id)
$nftType: 目前就hero
$tokenIdtokenid
*/
private function nftInfo($path)
{
if (count($path) < 5) {
return;
}
$netId = $path[2];
$nftType = $path[3];
$tokenId = $path[4];
echo json_encode(array(
'netId' => $netId,
'nftType' => $nftType,
'tokenId' => $tokenId
));
}
}