<?php /** * Authenticate/check if credentials is valid * * http://api.jotform.com/docs/#user */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { if ($response = $user->authenticate()) { echo "Authentication successful!\n"; print_r($response); } else { echo "Authentication failed!\n"; } } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user forms * * http://api.jotform.com/docs/#user-forms */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $options = ['offset' => 0, 'limit' => 30, 'filter' => json_encode(['new' => '1']), 'orderby' => 'created_at']; $forms = $user->getUserForms($options); print_r($forms); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Register user * * http://api.jotform.com/docs/#user-register */ require '../../vendor/autoload.php'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $response = $user->register(['username' => 'foobar', 'password' => 'myp@ssw0rd', 'email' => '*****@*****.**']); print_r($response); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Update user settings * * http://api.jotform.com/docs/#post-user-settings */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $options = ['name' => 'Foo Bar', 'company' => 'MyCompany Inc.']; $response = $user->updateUserSettings($options); print_r($response); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user folders * * http://api.jotform.com/docs/#user-folders */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $folders = $user->getUserFolders(); print_r($folders); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user information * * http://api.jotform.com/docs/#user */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $info = $user->getUser(); print_r($info); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user reports * * http://api.jotform.com/docs/#user-reports */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $reports = $user->getUserReports(); print_r($reports); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user history * * http://api.jotform.com/docs/#user-history */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $options = ['action' => 'all', 'date' => 'lastWeek', 'sortBy' => 'ASC', 'startDate' => '01/31/2013', 'endDate' => '12/31/2013']; $history = $user->getUserHistory($options); print_r($history); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Create a new form * * http://api.jotform.com/docs/#post-user-forms */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($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 = $user->createUserForm($myForm); print_r($response); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user settings * * http://api.jotform.com/docs/#user-settings */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $settings = $user->getUserSettings(); print_r($settings); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get sub-user account list * * http://api.jotform.com/docs/#user-subusers */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $subusers = $user->getUserSubUsers(); print_r($subusers); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get user submissions * * http://api.jotform.com/docs/#user-submissions */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $options = ['offset' => 0, 'limit' => 10, 'filter' => json_encode(['fullText' => 'John Brown']), 'orderby' => 'created_at']; $submissions = $user->getUserSubmissions($options); print_r($submissions); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Get monthly user usage * * http://api.jotform.com/docs/#user-usage */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $usage = $user->getUserUsage(); print_r($usage); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Login user using username/password credentials * * http://api.jotform.com/docs/#user-login */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $options = []; $response = $user->login('foobar', 'myp@ssw0rd', $options); print_r($response); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }
<?php /** * Logout user * * http://api.jotform.com/docs/#user-logout */ require '../../vendor/autoload.php'; $key = 'your-api-key-from-jotform'; $client = new JotForm\JotFormClient(); $client->setAPIKey($key); $user = new JotForm\Resource\User($client); try { $response = $user->logout(); print_r($response); } catch (\JotForm\Exception\ClientException $e) { echo $e->getMessage() . "\n"; }