1. Go to this page and download the library: Download yo1l/laravel-typeform library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$formChunks = TypeForm::getFormsByChunk();
foreach ($formChunks as $forms) {
foreach ($forms['items'] as $form) {
Log::info($form['id']);
}
}
$jsonForm = TypeForm::getForm($this->formSlug);
foreach ($jsonForm['fields'] as $item) {
// $item is a question / section
Log::debug($item)
if ($item['type'] == 'group') {
foreach ($item['properties']['fields'] as $subItem) {
Log::debug($subItem);
}
}
}
$params = ['completed' => true];
foreach (TypeForm::getResponsesByChunk("MyFormId", $params) as $responses) {
/**
1 response = 1 submitted forms
Each response contains all answers (unordered)
*/
foreach ($responses['items'] as $jsonResponse) {
$submitted_at = Carbon::parse($jsonResponse['submitted_at']);
$id = $jsonResponse['token'];
foreach ($jsonResponse['answers'] as $jsonAnswer) {
/**
Store your answers ?
*/
}
}
}
namespace App\Http\Controllers\API;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use TypeForm;
class TypeFormController extends Controller
{
public function __invoke(Request $request)
{
TypeForm::validatePayload($request);
$formId = $request->form_response['form_id'] ?? null;
abort_if($formId == null, 403);
/**
Do your stuff here
*/
return ['ok'];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.