Putting the Blaugh Daily Comic on your page.. (PHP)

This is kind of obfuscated, the blaugh daily comic went under, but I wanted to document the code I wrote to support this on your page, it may be useful for another site someday, or who knows my Chris Pirillo will bring back Blaugh, it was a good web comic..

Here is the PHP I wrote to display the daily Blaugh Comic on my site..

<?php
// code taken from blaugh api at <a href="http://blaugh.com/api/blaugh_api.pdf
//" title="http://blaugh.com/api/blaugh_api.pdf
//">http://blaugh.com/api/blaugh_api.pdf
//</a> and then modified a little.
$comic_data = file_get_contents('http://blaugh.com/api/php/1.0/getcomic/0');
$comic = unserialize($comic_data);
if (
$comic === false) {
        die (
'Could not get comic');
        }
?>

<br><br><br>
<center>
<table border="0">
<tr>
<th><?=$comic['title']?></th>
</tr>

<tr>
<td>
<a href="<?=$comic['permalink']?>" title="<?=$comic['title']?>">
<img src="<?=$comic['image_url']?>" alt="<?=$comic['title']?>" />
</a>
</td>
</tr>
</table>

And here is how I did it in the code module on website baker (I no longer run baker on my site, but someone might find it useful)

if (!$number) { $number=0;}
$previous = $_GET['h'] +1;
$next = $_GET['h']-1;
$comic_data = file_get_contents('http://blaugh.com/api/php/1.0/getcomic/'. $_GET['h']);
$comic = unserialize($comic_data);
if ($comic === false) {
         die ('Could not get comic');
        }
echo "<br><bR><br>";
echo "<center>";
echo "<table border='0'>";
echo "<tr>";
echo "<th>". $comic['title'] ."</th>";
echo "</tr>";


echo "<tr>";
echo "<td>";
echo "<a href=\"". $comic['permalink'] ."\" title=\"". $comic['title'] ."\" >";
echo "<img src=\"". $comic['image_url'] ."\" alt=\"". $comic['title'] ."\" >";
echo "</a>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<table border=0 width=100%><tr>";
echo "<td><div style='text-align:left'><a href='/?h=". $previous ."' align=left>Previous </a></td>";
if ($next  >= 0) {
echo "<td><div style='text-align: right;'><a href='/?h=". $next ."' align=right> Next </a></td>";
} else {
echo " <td><div style='text-align: right;'>Next</div></td>";
}
echo "</tr></table>";
echo "</td>";
echo "</tr>";
echo "</table>";

-Fratm

Powered by Drupal - Design by artinet