我一直在研究steam web api并提出请求。我决定使用的几种api方法是:
'https://api.steampowered.com/ISteamApps/GetAppList/v0001/?format=json' 'https://api.steampowered.com/ISteamApps/GetAppList/v0002/?format=json' 'https://api.steampowered.com/IGCVersion_440/GetServerVersion/v0001/?format=json'
这些来自此链接:http://api.steampowered.com/ISteamWebAPIUtil/GetSupportedAPIList/v0001/?format=json
我已经将它们全部作为浏览器上的常规网址链接进行了尝试,并且返回正常。
在Symfony上,我在我的代码上有这个代码:
/**
* @Route("/getClientVersion440")
*/
public function getClientVersion440()
{
$ch = curl_init();
$options = array(
CURLOPT_URL => 'http://api.steampowered.com/IGCVersion_440/GetClientVersion/v0001/?format=json',
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
return $this->render(
'custom/test.html.twig',
array('content' => json_decode($content))
);
}
/**
* @Route("/getSteamAppsListv1")
*/
public function getSteamAppsListv1()
{
$ch = curl_init();
$options = array(
CURLOPT_URL => 'https://api.steampowered.com/ISteamApps/GetAppList/v0001/?format=json',
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
return $this->render(
'custom/test.html.twig',
array('content' => json_decode($content))
);
}
/**
* @Route("/getSteamAppsListv2")
*/
public function getSteamAppsListv2()
{
$ch = curl_init();
$options = array(
CURLOPT_URL => 'https://api.steampowered.com/ISteamApps/GetAppList/v0002/?format=json',
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
return $this->render(
'custom/test.html.twig',
array('content' => json_decode($content))
);
}
在我的twig模板上,我有一个基于base.html.twig的自定义模板,我在这里显示数据如下:
<div class="container">
<div class="results">
{{dump(content)}}
</div>
</div>
第一个在symfony上正常工作,但另外2个返回null。我是symfony的新手,但我一直在寻找其他帖子来检查问题,并查看了探查器进行故障排除,但到目前为止,我不知道发生了什么。有人能指出我正确的方向吗?