Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
March 18, 2010, 06:22:53 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
WB 2.8.1 released!
Download and additional information are available
here
.
110327
Posts in
15933
Topics by
9291
Members
Latest Member:
topwzp
WebsiteBaker Community Forum
English
Archive (posts up to 2007)
(Moderators:
Argos
,
BerndJM
)
Would you like a free comic on your site?
Pages:
[
1
]
Author
Topic: Would you like a free comic on your site? (Read 5655 times)
Fratm
Offline
Posts: 100
Would you like a free comic on your site?
«
on:
December 20, 2006, 12:15:51 AM »
There is a comic I enjoy reading at blaugh.com, they released an API that allows you to have a daily comic on your site, so I wrote a little code that you can insert into a Code page, and it will give you a daily comic, and some navigation to view previous comics.
(SEE CODE BELOW..)
Enjoy!!
«
Last Edit: December 20, 2006, 05:58:46 PM by Fratm
»
Logged
kweitzel
Forum administrator
Offline
Posts: 5555
Re: Would you like a free comic on your site?
«
Reply #1 on:
December 20, 2006, 07:51:01 AM »
Nice script ... you just forgot to paste the "close" code of the last else-statement. Here is the corrected code (note the last line):
Code:
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>";
};
[Edit] Ahh ... yes and the previous/next links don't work in your code ..[/Edit]
cheers
Klaus
«
Last Edit: December 20, 2006, 07:56:19 AM by kweitzel
»
Logged
http://www.weitzel.biz
PM has been disabled
Fratm
Offline
Posts: 100
Re: Would you like a free comic on your site?
«
Reply #2 on:
December 20, 2006, 05:49:49 PM »
Hmm Working on my site (
http://wbtest.adnd.com
)
Here is the exact code I used.. maybe I posted my beta code..
(See Code below..)
«
Last Edit: December 21, 2006, 03:52:14 PM by Fratm
»
Logged
kweitzel
Forum administrator
Offline
Posts: 5555
Re: Would you like a free comic on your site?
«
Reply #3 on:
December 20, 2006, 07:03:56 PM »
maybe you did post a beta ... but still in this code the previous link does not work although the comic is beeing displayed ...
cheers
Klaus
Logged
http://www.weitzel.biz
PM has been disabled
Fratm
Offline
Posts: 100
Re: Would you like a free comic on your site?
«
Reply #4 on:
December 20, 2006, 11:43:53 PM »
Quote from: kweitzel on December 20, 2006, 07:03:56 PM
maybe you did post a beta ... but still in this code the previous link does not work although the comic is beeing displayed ...
cheers
Klaus
The code I posted is exactly what I am using at
http://testweb.adnd.com
and it works there.. So maybe there is something else going on?
-Steve
Logged
kweitzel
Forum administrator
Offline
Posts: 5555
Re: Would you like a free comic on your site?
«
Reply #5 on:
December 21, 2006, 09:02:20 AM »
and this is the code I tried ... check out the previous link here:
[Edit: Link removed]
cheers
Klaus
«
Last Edit: February 09, 2009, 07:21:18 AM by kweitzel
»
Logged
http://www.weitzel.biz
PM has been disabled
Fratm
Offline
Posts: 100
Re: Would you like a free comic on your site?
«
Reply #6 on:
December 21, 2006, 03:51:29 PM »
I know what's wrong.. And here is the code that fixes it (I hope).
Code:
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>";
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='". $_SERVER['SCRIPT_NAME'] ."?h=". $previous ."' align=left>Previous </a></td>";
if ($next >= 0) {
echo "<td><div style='text-align: right;'><a href='". $_SERVER['SCRIPT_NAME'] ."?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>";
The code was assuming 2 things.. 1) that you were calling this up from your first page, and 2) that your first page lived at / I changed it to get the actual script name that called it, and to use.. should work now.. sorry about the mess ups..
By the way, I run a small wiki, which is not publicly editable, I document my projects in there, and for this one I gave a special thanks to you for your help, I also put a link to your web site.. Thanks =)
http://www.fratm.com/index.php/Blaugh_php_api_code
-Steve
«
Last Edit: December 21, 2006, 04:02:12 PM by Fratm
»
Logged
kweitzel
Forum administrator
Offline
Posts: 5555
Re: Would you like a free comic on your site?
«
Reply #7 on:
December 21, 2006, 06:40:03 PM »
yep, that is it working now ... ready for release (Ever thought about a pagetype module for this kind of thing?)
cheers
Klaus
Logged
http://www.weitzel.biz
PM has been disabled
Fratm
Offline
Posts: 100
Re: Would you like a free comic on your site?
«
Reply #8 on:
December 21, 2006, 07:48:24 PM »
Quote from: kweitzel on December 21, 2006, 06:40:03 PM
yep, that is it working now ... ready for release (Ever thought about a pagetype module for this kind of thing?)
cheers
Klaus
Actually, funny that you mentioned it.. I was just thinking about doing that.. Maybe over Xmas break I will write one up.
-Steve
Logged
kweitzel
Forum administrator
Offline
Posts: 5555
Re: Would you like a free comic on your site?
«
Reply #9 on:
December 21, 2006, 09:02:46 PM »
Maybe design it from the beginning on, so that other comics can be added. A Friend of mine used to manually parse some sites (like dilbert) in Lotus Notes Script
But I take it, those sites could be parsed with curl (But be aware, that not every serverconfiguration supports CURL ... so in the beginning don't limit your Audience ...
cheers
Klaus
Logged
http://www.weitzel.biz
PM has been disabled
Fratm
Offline
Posts: 100
Re: Would you like a free comic on your site?
«
Reply #10 on:
December 21, 2006, 09:17:38 PM »
Quote from: kweitzel on December 21, 2006, 09:02:46 PM
Maybe design it from the beginning on, so that other comics can be added. A Friend of mine used to manually parse some sites (like dilbert) in Lotus Notes Script
But I take it, those sites could be parsed with curl (But be aware, that not every serverconfiguration supports CURL ... so in the beginning don't limit your Audience ...
cheers
Klaus
Yeah, maybe in version 2 =) This one is using the Blaugh API at
www.blaugh.com
.. Here is the first attempt at a module. (Works on my test page...)
Logged
kweitzel
Forum administrator
Offline
Posts: 5555
Re: Would you like a free comic on your site?
«
Reply #11 on:
December 22, 2006, 06:54:03 AM »
Just had a go on a XAMP System, does everything it needs to
Installation, Page and Deinstalation OK. Will check on a different system (LAMP) later on ...
cheers
Klaus
Logged
http://www.weitzel.biz
PM has been disabled
Pages:
[
1
]
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
Loading...