The API
Straight up
Just copy and paste the following:
<div id="sq-quote-wrapper">Loading..</div>
<script src="http://sunnyquotes.net/api/sq-api.js" id="sq-js" type="text/javascript" charset="utf-8"></script>
This is all you need to get a random quote on your page. You need to style it though, here is the final markup after the quote is loaded:
<div id="sq-quote-wrapper">
<div class="sq-quote"></div>
<div class="sq-who"></div>
<div class="sq-episode"></div>
</div>
Parameters
The API supports additional parameters being passed to the script:
- id: The id of the element where the quote should appear. Default is
#sq-quote-wrapper
. - quote: Set to
false
to not show the quote. Default istrue
. - who: Set to
false
to not show the quotes author. Default istrue
. - ep: Set to
false
to not show the episode. Default istrue
. - speed: Fade-in speed in milliseconds. Default is
800
. - click: Set to
true
to enable loading new quotes when the user clicks the container element. Default isfalse
.
Like so:
<script src="http://sunnyquotes.net/api/sq-api.js?id=MyElement&ep=false&click=true&speed=1500" id="sq-js" type="text/javascript" charset="utf-8"></script>
Demo:
Loading..
JSON
You can get the JSON for a random quote here:
http://sunnyquotes.net/q.php?random
or with a callback-parameter:
http://sunnyquotes.net/q.php?random&cb=MyCallback