{"id":441,"date":"2014-04-08T18:44:52","date_gmt":"2014-04-08T18:44:52","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=441"},"modified":"2015-08-20T11:34:15","modified_gmt":"2015-08-20T11:34:15","slug":"simple-official-spritz-api-usage","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/codeproject\/simple-official-spritz-api-usage\/","title":{"rendered":"Simple official Spritz API usage"},"content":{"rendered":"<p>TL;DR: See it in action <a href=\"http:\/\/www.nikola-breznjak.com\/codez\/spritz\/minimal.html\">here<\/a>\u00a0or <a href=\"http:\/\/www.nikola-breznjak.com\/codez\/spritz\/\">here<\/a>, and official site <a href=\"http:\/\/www.spritzinc.com\/\">here<\/a>.<\/p>\n<blockquote><p><a href=\"http:\/\/www.spritzinc.com\/\">Spritz<\/a> &#8211;\u00a0change the way people read and make communication faster, easier, and more effective.<\/p><\/blockquote>\n<p>So, there has been a lot of buzz about this lately and today I too got my API key to test this out. I must say that using Spritz is really easy, and they have a\u00a0<a href=\"http:\/\/sdk.spritzinc.com\/js\/1.0\/doc\/webhelp\/\">very good documentation<\/a>\u00a0with examples\u00a0so I will keep this short.<\/p>\n<p><span style=\"line-height: 1.5;\">After you register to their developer program you will get your API key. A simple use case to get you started is to make a HTML document with the following content:<br \/>\n<\/span><\/p>\n<pre class=\"lang:default decode:true\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;script type=\"text\/javascript\" src=\"jquery-2.1.0.min.js\"&gt;&lt;\/script&gt;\r\n\t&lt;script type=\"text\/javascript\"&gt;\r\n        var SpritzSettings = {\r\n            clientId: \"4aac1453ff37b364f\",\r\n            redirectUri: \"http:\/\/www.nikola-breznjak.com\/codez\/spritz\/login_success.html\",\r\n        };\r\n    &lt;\/script&gt;\r\n\r\n \t&lt;script type=\"text\/javascript\" src=\"spritz.min.js\"&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;h1&gt;Spritz test&lt;\/h1&gt;\r\n\r\n  \t&lt;div data-role=\"spritzer\"&gt;&lt;\/div&gt;\r\n\r\n    &lt;div&gt;This is some demo text that will be Spritzt&lt;\/div&gt;\r\n  \t&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>Important things to note here are that Spritz uses <a href=\"http:\/\/jquery.com\/\">jQuery<\/a> and you have to use your clientId and put <a href=\"http:\/\/www.nikola-breznjak.com\/codez\/spritz\/login_success.html\">this rediretUri file<\/a>\u00a0to your server (on which you host the domain with which you registered your Spritz application).<\/p>\n<p>A little more advanced example is here:\u00a0<a href=\"http:\/\/www.nikola-breznjak.com\/codez\/spritz\/\">http:\/\/www.nikola-breznjak.com\/codez\/spritz\/<\/a>\u00a0(you can just view the source of it and I&#8217;m sure you&#8217;ll know how to take it from there).<\/p>\n<p>Worth noting is that there are some open source versions of this like <a href=\"https:\/\/github.com\/Miserlou\/OpenSpritz\">Open Spritz<\/a>, though I think this one is way better as it has whole research and <a href=\"http:\/\/www.spritzinc.com\/the-science\/\">the science<\/a> behind it.<\/p>\n<p>Using this on a simple HTML page was, well, simple. I tried to incorporate this into my wordpress blog (the one you&#8217;re reading right now), and though it works nicely when I put the code in the index.php file (the main template file which lists all of the posts), it does not work when I put the same exact code to the single.php (template for showing specific posts). The error that I&#8217;m getting in the latter case is this:<\/p>\n<pre class=\"lang:default decode:true\">Unable to spritz: Unable to retrieve contentVersion, contentId=5343e07be4b063e2752c379b: HTTP call failed, status: 500, message: Internal Server Error<\/pre>\n<p>So, if someone got the same error, how did you go about it?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR: See it in action here\u00a0or here, and official site here. Spritz &#8211;\u00a0change the way people read and make communication faster, easier, and more effective. So, there has&hellip;<\/p>\n","protected":false},"author":1,"featured_media":442,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,27],"tags":[29,28],"class_list":["post-441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeproject","category-javascript","tag-speed-reading","tag-spritz"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":6,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":451,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions\/451"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/442"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}