I want to use the PHP Simple HTML DOM Parser to display all my Left4Dead Steam achievements on my website. The achievements list on the steam community website looks something like this:
<img src="…" /><br />
<div class="achieveImgHolder"><img src="…" /></div>
<div class="achieveTxtHolder">
<img src="…" />
<div class="achieveTxt">
<h3>Stand Tall</h3>
<h5>Survive a campaign without being incapacitated.</h5>
</div>
</div>
<br clear="left" />
Active achievements are separated from inactive achievements by
<br /><br /><br />
So I wrote the this code to display my achievements:
<?php
include("simple-html-dom-parser.php");
$achievementPage = file_get_html("http://steamcommunity.com/id/snorpey/stats/L4D?tab=achievements");
$activeInactiveSplit = split("<br /><br /><br />", $achievementPage);
$actives = str_get_html($activeInactiveSplit[0]);
$inactives = str_get_html($activeInactiveSplit[1]);
foreach($actives->find(".achieveTxtHolder") as $achievement)
{
echo $achievement->find(".achieveTxt h3", 0)->innertext;
}
?>
I always get the following error and have no idea where comes from.
Fatal error: Call to a member function find() on a non-object in testing.php on line 8
I tested the parser with another part of the page and it worked properly. It seems to have problems with splitting the page.
echo $actives // works w/out errors
What exactly went wrong here?