带有编码网址的file_get_contents

时间:2014-08-25 05:52:56

标签: php

我在使用我编码的网址时遇到了一些问题,我收到了此错误,而且我不知道如何修复它。

  

警告:file_get_contents(%27http%3A%2F%2Fapi.steampowered.com%2FISteamUser%2FGetPlayerSummaries%2Fv0002%2F%3Fkey%3D%27 + .. +%27%26steamids%3D%27 + ..)[ function.file-get-contents]:无法打开流:没有这样的文件或目录。

是不是在我的主目录之外?有谁知道如何制作网址功能?

任何帮助都会很棒!

<?php

$url= "'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .$apikey. '&steamids=' .$keyword.";
$string=file_get_contents(urlencode($url));

$json_a=json_decode($string,true);

$json_o=json_decode($string);
//array method
foreach($json_a[personaname] as $p)
{
echo '
<p>
Name: '.$p[response][players][personaname].'

';

}

?>

1 个答案:

答案 0 :(得分:0)

将您的网址仅包含在一种类型的引号中:

$url= "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . $apikey .  '&steamids=' . $keyword;