The purpose behind this project is the database for the Android and iPhone Quote of the Day app. This page essentially pulls the same information and behaves the same as the apps. It was necessary to get this page up and running before even beginning work on the apps.
This page is 100% complete. As of 9/21/2017, both of the mobile apps are complete too. Well, this was true until Nov, 2020 when I dropped support for all Apple apps and removed it from the store. So, we're back to only the Android version. Sorry.
Note 2020-11-21: I am making some upgrades to the API as well as a couple of the programs that go along with it. If things break, then things break. "I don't always test my code, but when I do, I test it in production" -Abraham Lincoln
Social icons appear here
NEW: As a matter of showing how the API can work on a site that is not this site, I created a full-page stand-alone version of this program. Literally all it does is call up the current quote. It also includes a "more" section to show the rest of the data that goes along with it, that is normally not seen.
I have created a Twitter Bot for this. If you don't want to download the app, you can follow the Twitter account, and get your daily quote there.
Follow @DPQuoteOfTheDayCurrent status of the apps - 08-15-2017: Android App is 100% finished.
API
An Application Programming Interface is an interface or communication protocol between a client and a server intended to simplify the building of client-side software. In short, if you need to perform the same function over and over again, like pulling a record from a database, it is sensible to write a single API that can be called from anywhere at any time, that does nothing but return the desired result.
We are making the API that makes this thing run open to anyone that wants to use it. The database now holds some 4 years worth of quotes. And there are always more coming in. Users submit new quotes about as often as I do. I have already used this project for a number of things, and I suspect that people would probably find it useful for their own projects. So we are allowing the API to be used openly. As long as this service doesn't get abused, it will remain free for the foreseeable future.
The link to call the API is:
https://android.dpoisn.com/quotes/showquote.php?echoquote=2
Running the API right now will return the JSON:
[["281","Knowledge speaks, but wisdom listens.","Jimi Hendrix","Gabriel Robins","2017-07-24 00:00:00","","Internet","2024-10-06","http:\/\/www.cs.virginia.edu\/~robins\/quotes.html","Wisdom"]]
The argument "echoquote=2" tells the API to return just today. If you use "echoquote=3", it will return 30 days worth. It starts with today minus 1 week and goes out 3 weeks. The following code really only addresses a single quote. If you wish to use the 30-day version, modify the code to utilize the entire array, rather than just element [0].
To make practical use of this, you will have to parse that JSON. In other words, make it into an array that you can use. You can do this any way you like. JavaScript is probably the easiest, since you will probably use JavaScript to make the initial call to the API.
This is easier than it sounds because it's already an array. You just need to know what the elements are:
0: Id
1: Quote
2: Author
3: Attributed to
4: Date Entered
5: Notes
6: Source
7: Date FOR (today's date)
8: Link for attribution
9: Category
The output can look like this:
Code for this:
Since I used PHP to call up the JSON, I used a PHP variable $quoteIs
<?php $quoteIs = file_get_contents('https://android.dpoisn.com/quotes/showquote.php?echoquote=2'); ?> <script type="text/javascript"> var quoteIs = <? echo $quoteIs; ?>; document.writeln('Quote for: ' + quoteIs[0][7] + '<br />'); document.writeln(quoteIs[0][1] + '<br />'); document.writeln('- ' + quoteIs[0][2]); </script>