JotForm API - PHP Client
PHP
Latest commit 57981af Jan 4, 2017 @kenma9123 kenma9123 committed on GitHub Merge pull request #7 from TheDigitalOrchard/TheDigitalOrchard-patch-1
improve ws consistency, string formatting
Permalink
Failed to load latest commit information.
JotForm.php Update JotForm.php Dec 29, 2016
LICENSE Create LICENSE Sep 15, 2013
README.md Small readme fix Aug 14, 2013
composer.json classmap for JotForm Sep 1, 2013

README.md

jotform-api-php

JotForm API - PHP Client

Installation

Install via git clone:

    $ git clone git://github.com/jotform/jotform-api-php.git
    $ cd jotform-api-php

or

Install via Composer package manager (http://getcomposer.org/)

composer.json

    {
        "require": {
            "jotform/jotform-api-php": "dev-master"
        }
    }
    $ php composer.phar install

Documentation

You can find the docs for the API of this client at http://api.jotform.com/docs/

Authentication

JotForm API requires API key for all user related calls. You can create your API Keys at API section of My Account page.

Examples

Print all forms of the user

<?php

    include "jotform-api-php/JotForm.php";

    $jotformAPI = new JotForm("YOUR API KEY");
    $forms = $jotformAPI->getForms();

    foreach ($forms as $form) {
        print $form["title"];
    }

?>

Get submissions of the latest form

<?php

    try {
        include "jotform-api-php/JotForm.php";

        $jotformAPI = new JotForm("YOUR API KEY");

        $forms = $jotformAPI->getForms(0, 1, null, null);

        $latestForm = $forms[0];

        $latestFormID = $latestForm["id"];

        $submissions = $jotformAPI->getFormSubmissions($latestFormID);

        var_dump($submissions);

    }
    catch (Exception $e) {
        var_dump($e->getMessage());
    }

?>

Get latest 100 submissions ordered by creation date

<?php

    try {
        include "jotform-api-php/JotForm.php";

        $jotformAPI = new JotForm("YOUR API KEY");

        $submissions = $jotformAPI->getSubmissions(0, 100, null, "created_at");

        var_dump($submissions);
    }
    catch (Exception $e) {
        var_dump($e->getMessage());
    }

?>

Submission and form filter examples

<?php

    try {
        include "jotform-api-php/JotForm.php";

        $jotformAPI = new JotForm("YOUR API KEY");

        $filter = array(
                "id:gt" => "239252191641336722",
                "created_at:gt" => "2013-07-09 07:48:34",
        );

        $subs = $jotformAPI->getSubmissions(0, 0, $filter, "");
        var_dump($subs); 

        $filter = array(
                "id:gt" => "239176717911737253",
        );

        $formSubs = $jotformAPI->getForms(0, 0, 2, $filter);
        var_dump($formSubs);
    } catch (Exception $e) {
            var_dump($e->getMessage());
    }

?>

Delete last 50 submissions

<?php

    try {
        include "jotform-api-php/JotForm.php";

        $jotformAPI = new JotForm("YOUR API KEY");

        $submissions = $jotformAPI->getSubmissions(0, 50, null, null);

        foreach ($submissions as $submission) {
            $result = $jotformAPI->deleteSubmission($submission["id"]);
            print $result;
        }
    }
    catch (Exception $e) {
        var_dump($e->getMessage());
    }

?>

First the JotForm class is included from the jotform-api-php/JotForm.php file. This class provides access to JotForm's API. You have to create an API client instance with your API key. In case of an exception (wrong authentication etc.), you can catch it or let it fail with a fatal error.