Click here to Skip to main content
12,244,802 members (50,602 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.2K views
Posted

Simple official Spritz API usage

, 10 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
TL;DR: See it in action here or here, and official site here. Spritz - change the way people read and make communication faster, easier, and more effective. 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 […]

TL;DR: See it in action here or here, and official site here.

Spritz - change the way people read and make communication faster, easier, and more effective.

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 very good documentation with examples so I will keep this short.

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:

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="jquery-2.1.0.min.js"></script>
    <script type="text/javascript">
        var SpritzSettings = {
            clientId: "4aac1453ff37b364f",
            redirectUri: "http://www.nikola-breznjak.com/codez/spritz/login_success.html",
        };
    </script>

     <script type="text/javascript" src="spritz.min.js"></script>
</head>

<body>
    <h1>Spritz test</h1>

      <div data-role="spritzer"></div>

    <div>This is some demo text that will be Spritzt</div>
      </div>
</body>
</html>

Important things to note here are that Spritz uses jQuery and you have to use your clientId and put this rediretUri file to your server (on which you host the domain with which you registered your Spritz application).

A little more advanced example is here: http://www.nikola-breznjak.com/codez/spritz/ (you can just view the source of it and I’m sure you’ll know how to take it from there).

Worth noting is that there are some open source versions of this like Open Spritz, though I think this one is way better as it has whole research and the science behind it.

Using this on a simple HTML page was, well, simple. I tried to incorporate this into my wordpress blog (the one you’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’m getting in the latter case is this:

Unable to spritz: Unable to retrieve contentVersion, contentId=5343e07be4b063e2752c379b: HTTP call failed, status: 500, message: Internal Server Error

So, if someone got the same error, how did you go about it?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nikola Breznjak
Web Developer
Croatia Croatia
Nikola Brežnjak is an engineer at heart and a jack of all trades kind of guy.

For those who care about titles, he has a masters degree in computing from FER. For the past 7 years he worked in a betting software industry where he made use of his knowledge in areas ranging from full stack (web & desktop) development to game development through Linux and database administration and use of various languages (C#, PHP, JavaScript to name just a few).

Lately he’s been interested in the MEAN stack, Ionic framework and Unity3D. Also, he likes to help out on StackOverflow where he’s in the top 0.X% currently.

Come and see what I write about on my blog.

My book on MEAN stack.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 10 Apr 2014
Article Copyright 2014 by Nikola Breznjak
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid