Blaugh php api code
From Fratm.com
Code to pull up Blaugh Comic in PHP
This is the code that I used to put the Blaugh daily comic on my web site.
<?php
// code taken from blaugh api at http://blaugh.com/api/blaugh_api.pdf
// 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>
Here is how I did it in a code module for Website Baker
Revision #3... Special thanks to kweitzel at the Website Baker forums for his help trouble shooting this..
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>";
