Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 11, 2012, 05:37:04 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
149534
Posts in
21088
Topics by
7529
Members
Latest Member:
schwaneb
WebsiteBaker Community Forum
English
Archive (posts up to 2007)
(Moderator:
Argos
)
Would you like a free comic on your site?
Pages: [
1
]
Go Down
Author
Topic: Would you like a free comic on your site? (Read 6254 times)
Fratm
Offline
Posts: 101
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: 6817
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
WebsiteBaker Org e.V. - for WebsiteBaker
Fratm
Offline
Posts: 101
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: 6817
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
WebsiteBaker Org e.V. - for WebsiteBaker
Fratm
Offline
Posts: 101
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: 6817
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
WebsiteBaker Org e.V. - for WebsiteBaker
Fratm
Offline
Posts: 101
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: 6817
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
WebsiteBaker Org e.V. - for WebsiteBaker
Fratm
Offline
Posts: 101
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: 6817
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
WebsiteBaker Org e.V. - for WebsiteBaker
Fratm
Offline
Posts: 101
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: 6817
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
WebsiteBaker Org e.V. - for WebsiteBaker
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
-----------------------------
English
-----------------------------
=> Help & Support
-----------------------------
General
-----------------------------
=> WebsiteBaker Website Showcase
-----------------------------
English
-----------------------------
=> Modules
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
-----------------------------
General
-----------------------------
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
-----------------------------
General
-----------------------------
=> Security Announcements
-----------------------------
Deutsch (German)
-----------------------------
=> Hilfe/Support
-----------------------------
General
-----------------------------
=> Documentation
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
=> Module & Snippets
-----------------------------
English
-----------------------------
=> Archive (posts up to 2007)
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Deutsch (German)
-----------------------------
=> jQuery
=> Tutorials
=> Templates & Design
-----------------------------
English
-----------------------------
=> jQuery
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
===> Suggestions
-----------------------------
Deutsch (German)
-----------------------------
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
===> Vorschläge
-----------------------------
English
-----------------------------
===> Software bugs
-----------------------------
Deutsch (German)
-----------------------------
===> Softwarefehler
=====> Module / Extensions
-----------------------------
English
-----------------------------
=====> Modules / Extensions
-----------------------------
Deutsch (German)
-----------------------------
===> Erfahrungs und Testberichte
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...