PHP简单的HTML DOM对外输出空白页(PHP Simple HTML DOM Outputti

2019-10-18 00:57发布

所以,我试图输出玩L4D2(游戏ID 550)一个人的游戏时间,虽然这个脚本用来工作,现在只输出使用这个“PHP简单的HTML DOM”空白页我已经备份了这里的http:/ /rghost.net/45405596 。 如果我下载并尝试使用最新的简单DOM从他们的网站,而不是深藏不露它显示

调用未定义功能file_get_dom()第9" 行

这里是我运行的代码

    <?php
    ini_set('memory_limit', '-1');
    include('simple_html_dom.php');
    $lines = file('profile2.txt');                                                       //reads in the file with the list of user numbers
    foreach ($lines as $usernumber) {                                                  //loops line by line
    $link = "http://steamcommunity.com/profiles/<sitenumber>/games?tab=all";   //link format
    $link = preg_replace('/(<sitenumber>)/i',$usernumber,$link);               //puts usernumber into link format
    $link = preg_replace('/\s*/m','',$link);                                   //remove the stupid space
    $html = file_get_dom($link);                                               //calls the dom function
    $divline = $html->find('div[id=game_550] h5', 0);                          //finds the div block and then the h5 line
    $divline = preg_replace('/(<(\/)?h5>)/i', '', $divline);                   //replaces the <h5> tag with nothing
    if ($divline != '') {
        list($hrs,$u1,$u2,$u4) = explode(" ",$divline);
        if (($hrs < 90) && ($hrs > 1)) {
            echo $hrs." - ".$link."<br>";                                  //prints results
        }
    }
    $html->__destruct();
    unset($html); 
while(@ob_end_clean()); 


}
?>

这指向包含这个号码“76561198049810642”一个名为profile3.txt文本文件

任何建议,这是为什么输出什么? 万分感谢!

Answer 1:

下面是一些(未经测试)的代码,应该可以帮助您使用上手蒸汽的Web API :

$api_key = '...';
$steam_id = '...';
$game_id = 550;

$json = file_get_contents('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=' . $api_key . '&steamid=' . $steam_id . '&format=json');

$data = json_decode($json);
foreach ($data->response->games as $game) { 
    if ($game->appid == $game_id) {
        echo 'Playtime for ', $game_id, ' is ' . $game->playtime_forever;
    }
}


文章来源: PHP Simple HTML DOM Outputting Blank Page