Get Started

Sign up
Sign up for the free version of phz.io and give it a spin. Up to 250k transactions per month, no credit card required.

Sign upPricing

Get Started Guide

Login to the Console
  • Within the Console you can manage your user acccess and security.
  • Get a client token for api auth.
  • View and manage your fans and consumers.
  • Create engagements, create loyalty programs, add gamification, and much more.
Hello World

First lets setup our dependencies

<html>
  <head>
      <script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
      <script  src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
  </head>
  <body>
  </body>
</html>

Then lets create a basic HTML form

<html>
  <head>
      <script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
      <script  src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
  </head>
  <body>
      <form>
          <label for="firstname">First Name</label>
          <input id="firstname"> <p/>
          <label for="lastname">Last Name</label>
          <input id="lastname"><p/>
          <label for="email">Email</label>
          <input id="email" type="email"><p/>
          <!--add the button and the onclick action -->
          <button type="button" onclick="createFan();">Submit</button>
      </form>
  </body>
</html>

Then lets create a simple script that calls the /fan/create api and an area for our results

<script>
   function createFan(){
          var postBody = {};
          postBody.fan = {};
          postBody.profiles = [];
          postBody.fan.firstname = document.getElementById("firstname").value;
          postBody.fan.lastname = document.getElementById("lastname").value;
          var profile = {};
          profile.type = 'Email';
          profile.profile = document.getElementById("email").value;
          postBody.profiles.push(profile);
          console.log(JSON.stringify(postBody));
          var endpoint = 'http://phz.io/fan/create?token='
          // add your client token here ...
          var token = 'your token here';
          $.ajax({
              url : endpoint + token,
              type: "POST",
              data : JSON.stringify(postBody),
              contentType: 'application/json',
              success: function(data, status)
              {
                  console.log(data);
                  console.log(status);
                  document.getElementById("results").innerHTML = JSON.stringify(data, null, 2);
              },
              error: function (jqXHR, status, errorThrown)
              {
                  console.log(errorThrown);
                  console.log(status);
                  console.log(jqXHR);
              }
          });
      }
</script>

Then lets add that action to our form

<form>
  <label for="firstname">First Name</label>
  <input id="firstname"> <p/>
  <label for="lastname">Last Name</label>
  <input id="lastname"><p/>
  <label for="email">Email</label>
  <input id="email" type="email"><p/>
  <!--add the button and the onclick action -->
  <button type="button" onclick="createFan();">Submit</button>
</form>
  <!--add these tags to display the results -->
<pre class="prettyprint" style="min-height:500px;" id="results">
</pre>

And you're are good to go... finish product should look like this

<html>
<head>
    <script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
    <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
    <script>
        function createFan() {
            var postBody = {};
            postBody.fan = {};
            postBody.profiles = [];
            postBody.fan.firstname = document.getElementById("firstname").value;
            postBody.fan.lastname = document.getElementById("lastname").value;
            var profile = {};
            profile.type = 'Email';
            profile.profile = document.getElementById("email").value;
            postBody.profiles.push(profile);
            console.log(JSON.stringify(postBody));
            var endpoint = 'http://phz.io/fan/create?token='
            // add your client token here ...
            var token = 'your token here';
            $.ajax({
                url: endpoint + token,
                type: "POST",
                data: JSON.stringify(postBody),
                contentType: 'application/json',
                success: function (data, status) {
                    console.log(data);
                    console.log(status);
                    document.getElementById("results").innerHTML = JSON.stringify(data, null, 2);
                },
                error: function (jqXHR, status, errorThrown) {
                    console.log(errorThrown);
                    console.log(status);
                    console.log(jqXHR);
                }
            });
        }
    </script>
</head>
<body>
  <form>
      <label for="firstname">First Name</label>
      <input id="firstname">
      <p/>
      <label for="lastname">Last Name</label>
      <input id="lastname">
      <p/>
      <label for="email">Email</label>
      <input id="email" type="email">
      <p/>
      <button type="button" onclick="createFan();">Submit</button>
  </form>
  <pre class="prettyprint" style="min-height:500px;" id="results">
  </pre>
</body>
</html>