<?php

/**
 * Get form reports
 *
 * http://api.jotform.com/docs/#form-id-reports
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $reports = $form->getFormReports($formId);
    print_r($reports);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Add/edit properties of a specific form
 *
 * http://api.jotform.com/docs/#post-form-id-properties
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $properties = ['properties' => ['thankurl' => 'http://www.mywebsite.com/thank-you-page.html']];
    $response = $form->updateFormProperties($formId, $properties);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
Ejemplo n.º 3
0
<?php

/**
 * Create a form
 *
 * http://api.jotform.com/docs/#post-forms
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $myForm = ['questions' => [['type' => 'control_head', 'text' => 'Form Title', 'order' => 1, 'name' => 'Header'], ['type' => 'control_textbox', 'text' => 'Text Box Title', 'order' => 2, 'name' => 'TextBox', 'validation' => 'None', 'required' => 'No', 'readonly' => 'No', 'size' => 30, 'labelAlign' => 'Auto', 'hint' => 'Hint: Lorem Ipsum']], 'properties' => ['title' => 'My Form', 'height' => 600], 'emails' => ['type' => 'notification', 'name' => 'notification', 'from' => 'default', 'to' => '*****@*****.**', 'subject' => 'New Submission', 'html' => 'false']];
    $response = $form->createForm($myForm);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
Ejemplo n.º 4
0
<?php

/**
 * Clone form
 *
 * http://api.jotform.com/docs/#post-form-id-clone
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $response = $form->cloneForm($formId);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Delete form question
 *
 * http://api.jotform.com/docs/#delete-form-id-question-id
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $questionId = '1';
    $response = $form->deleteFormQuestion($formId, $questionId);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get form uploads
 *
 * http://api.jotform.com/docs/#form-id-files
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $uploads = $form->getFormUploads($formId);
    print_r($uploads);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get form submissions
 *
 * http://api.jotform.com/docs/#form-id-submissions
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $options = ['offset' => 0, 'limit' => 10, 'filter' => json_encode(['created_at:gt' => '2013-01-01 00:00:00']), 'orderby' => 'created_at'];
    $response = $form->getFormSubmissions($formId, $options);
    // With options
    // $response = $form->getFormSubmissions($formId); // Without options
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
Ejemplo n.º 8
0
<?php

/**
 * Delete a form
 *
 * http://api.jotform.com/docs/#delete-form-id
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $response = $form->deleteForm($formId);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Add new question to specified form
 *
 * http://api.jotform.com/docs/#post-form-id-questions
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $newQuestion = ['question' => ['type' => 'control_textbox', 'text' => 'Sample Text Box Title', 'order' => 3, 'name' => 'SampleTextBox', 'validation' => 'None', 'required' => 'No', 'readonly' => 'No', 'size' => 20, 'labelAlign' => 'Auto', 'hint' => 'Hint: Sample text box hint']];
    $response = $form->addFormQuestion($formId, $newQuestion);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
Ejemplo n.º 10
0
<?php

/**
 * Get form details
 *
 * http://api.jotform.com/docs/#form-id
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $formDetails = $form->getForm($formId);
    print_r($formDetails);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get form webhooks
 *
 * http://api.jotform.com/docs/#form-id-webhooks
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $webhooks = $form->getFormWebhooks($formId);
    print_r($webhooks);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get form questions
 *
 * http://api.jotform.com/docs/#form-id-questions
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $questions = $form->getFormQuestions($formId);
    print_r($questions);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get details about a question
 *
 * http://api.jotform.com/docs/#form-id-question-id
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $questionId = '1';
    $questionDetails = $form->getFormQuestionDetails($formId, $questionId);
    print_r($questionDetails);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get a form property
 *
 * http://api.jotform.com/docs/#form-id-properties-key
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $key = 'thankurl';
    $property = $form->getFormProperty($formId, $key);
    print_r($property);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Get form properties
 *
 * http://api.jotform.com/docs/#form-id-properties
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $properties = $form->getFormProperties($formId);
    print_r($properties);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Create report
 *
 * http://api.jotform.com/docs/#post-form-id-reports
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $report = ['title' => 'Report Title', 'list_type' => 'grid', 'fields' => 'ip,dt,2'];
    $response = $form->createFormReport($formId, $report);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Create new webhook
 *
 * http://api.jotform.com/docs/#post-form-id-webhooks
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $webhook = ['webhookURL' => 'http://www.mywebsite.com/jotform/webhook'];
    $response = $form->createFormWebhook($formId, $webhook);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Update a single question properties
 *
 * http://api.jotform.com/docs/#post-form-id-question-id
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $questionId = '1';
    $questionUpdate = ['question' => ['name' => 'Header', 'order' => 1, 'text' => 'Updated Form Title', 'type' => 'control_head']];
    $questionDetails = $form->updateFormQuestion($formId, $questionId, $questionUpdate);
    print_r($questionDetails);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Delete a webhook of a specific form
 *
 * http://api.jotform.com/docs/#delete-form-id-webhooks
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $webhookId = 0;
    $response = $form->deleteFormWebhook($formId, $webhookId);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}
<?php

/**
 * Add a submission to a form
 *
 * http://api.jotform.com/docs/#post-form-id-submissions
 */
require '../../vendor/autoload.php';
$key = 'your-api-key-from-jotform';
$client = new JotForm\JotFormClient();
$client->setAPIKey($key);
$form = new JotForm\Resource\Form($client);
try {
    $formId = 'form-ID-here';
    $submission = ['submission' => ['2' => 'Lorem ipsum', '3' => '*****@*****.**', '4' => ['Foo', 'Bar']]];
    $response = $form->addFormSubmission($formId, $submission);
    print_r($response);
} catch (\JotForm\Exception\ClientException $e) {
    echo $e->getMessage() . "\n";
}