In order to make it easier for other sites to incorporate the M'Cheyne daily Bible readings into their own pages I have created the M'Cheyne server. The source code is available, and you can see the raw output. The server can make URLs linking to any of eight different Bible versions; it can deliver readings based on either the Classic or the Carson variants of the calendar; and it even understands timezones.
When you access the URL of the server it delivers up that day's readings in a form that is easily interpreted by a PHP or Perl script. I have written a PHP class that can be used to interrogate the server and interpret the data which is described below.
You are free to use either the class or the M'Cheyne data server directly on the condition that you include on any web page that uses the data from the server a readable acknowledgement similar to one of the following (at your option),
I'd be glad to help get this up and running for you, so feel free to contact me me. And please drop me a line if you do use the data on your web page. Have a look at my M'Cheyne page for more information about Robert Murray M'Cheyne's daily Bible reading plan.
To use the server to include the M'Cheyne readings in your own
webpages you first need to make sure that your webserver is able to
run PHP. The page in which you want to include the readings
should be given an extension ".php" rather than
".html" or ".htm". I will refer to it as
mcheyne.php for convenience. In the following everything
between <?php and ?> markers is PHP
script. It can be freely interspersed with HTML.
First copy the server access class, data.inc and save it on your own server.
Next insert the following code into your mcheyne.php page somewhere near the top.
<?php
include "data.inc";
$mc = new McheyneData('niv', 'classic', 0);
?>
The McheyneData constructor takes four parameters, all of which are optional.
When the $mc object is created it will automatically
interrogate the M'Cheyne server and set up several variables which you
can then use in your web page.
| $mc->version | Version number of the server |
|---|---|
| $mc->day | Day of the year |
| $mc->mday | Day of the month |
| $mc->month | Month name |
| $mc->year | The year |
| $mc->tz | The timezone |
| $mc->quote | The M'Cheyne Bible quote for the month |
| $mc->cal | Calendar version |
| $mc->bible | Bible version |
| $mc->refs | Array of Bible references |
| $mc->urls | Array of URLs pointing to Bible texts |
As an example, I use the following code to show my current readings on my homepage,
<?php
include "data.inc";
$mc = new McheyneData('niv', 'carson', 0);
if ($mc->year % 2) {
$ref1 = $mc->refs[2];
$ref2 = $mc->refs[3];
$url1 = $mc->urls[2];
$url2 = $mc->urls[3];
} else {
$ref1 = $mc->refs[0];
$ref2 = $mc->refs[1];
$url1 = $mc->urls[0];
$url2 = $mc->urls[1];
}
echo "<a href=\"$url1\">$ref1</a>, <a href=\"$url2\">$ref2</a>";
?>
Outside the PHP region you can simply insert the data into ordinary HTML like this, for example
<?php
include "data.inc";
$mc = new McheyneData('niv', 'carson', 0);
?>
<h1>
M'Cheyne readings for <?php echo $mc->mday." ".$mc->month." ".$mc->year; ?>
</h1>
<p>These are today's readings,</p>
<ul>
<li><?php echo $mc->refs[0]; ?></li>
<li><?php echo $mc->refs[1]; ?></li>
<li><?php echo $mc->refs[2]; ?></li>
<li><?php echo $mc->refs[3]; ?></li>
</ul>
For a real example of this have a look at the source code for the interactive M'Cheyne calendar.
In case you are interested in this kind of stuff, the document served up by the M'Cheyne server is a valid and well-formed XML 1.0 document with a suitable DTD. It also includes an XML stylesheet so that, if your browser supports it, the XML document is transformed into viewable HTML on access. Mozilla 1.0, Netscape 7 and Internet Explorer 6 seem to handle this reliably, but Opera doesn't support it. If you point one of these browsers at the server you should see a simple webpage with the data nicely formatted rather than the raw output. See my XML & XSL page for more information.
Another option for using the readings is to use the M'Cheyne RSS feed. This is certainly a convenient way to access the readings on a day-to-day basis.
Currently the M'Cheyne server just uses the HTTP GET protocol and delivers up its own XML. I am contemplating implementing it as a SOAP service so that it can be used as a web service in standard ways. If this would be of interest to you then please drop me a line and I'll look into it a bit further.