@picsoung or @mathio do either of you happen to know? I’m not familiar with PHP. 
Hi @Pako69
I used to work with PHP some time ago. Can you please share your full script (how you load the data) so I can run it locally?
Here is
$data = json_decode(file_get_contents('php://input'));
$infos = $data->form_response;
$answers = $data->form_response->answers;
// THIS BELOW DO NOT RETURN ANYTHING -------------------
echo $infos->event_id.' XXX';
echo $infos->form_response->definition->title.' XXX';
// -----------------------------------------------------
// THE REST BELOW OF THE SCRIPT IS OK ______________
$expfile = 'testtypeform.txt';
$myfile = fopen($expfile, 'r') or die("Unable to open file!");;
$line = fgets($myfile);
if ($line = 'id Date Formulaire Raison_Sociale Civilite Nom Prenom Email Telephone Pays Objet Commentaire BU Origine') {
$headers_set = TRUE;
}
fclose($myfile);
$myfile = fopen($expfile, "a") or die("Unable to open file!");
if (!$headers_set) {
$headers = 'id'."\t".'Date'."\t".'Formulaire'."\t".'Raison_Sociale'."\t".'Civilite'."\t".'Nom'."\t".'Prenom'."\t".'Email'."\t".'Telephone'."\t".'Pays'."\t".'Objet'."\t".'Commentaire'."\t".'BU'."\t".'Origine'."\n\n";
fwrite($myfile, $headers);
}
foreach ($answers as $answer) {
switch ($answer->type) {
case 'text':
if ($answer->field->ref == 'prenom'):
//echo $answer->text.' ';
$prenom .= utf8_decode($answer->text);
elseif ($answer->field->ref == 'nom'):
//echo $answer->text.' ';
$nom .= utf8_decode($answer->text);
elseif ($answer->field->ref == 'societe'):
//echo $answer->text.' ';
$societe .= utf8_decode($answer->text);
else:
//echo $answer->field->ref.' : ';
//echo $answer->text.' - ';
$autre .= utf8_decode($answer->text);
endif;
break;
case 'email':
//echo $answer->email.' ';
$email = $answer->email;
break;
case 'phone_number':
//echo $answer->phone_number.' ';
$telephone = $answer->phone_number;
break;
default:
if ($answer->type == 'boolean'):
//echo $answer->field->ref.' : ';
$autres .= utf8_decode($answer->field->ref);
switch ($answer->boolean) {
case TRUE:
//echo 'Oui ';
$autres .= ' Oui ';
break;
case FALSE:
//echo 'Non ';
$autres .= ' Non ';
break;
}
elseif ($answer->type == 'choice'):
$autres .= utf8_decode(' '.$answer->field->ref).' ';
$autres .= utf8_decode(' '.$answer->choice->label).' ';
//echo $answer->field->ref.' : ';
//echo $answer->choice->label.' ';
else:
echo $answer->text.' INCONNU ';
endif;
}
$data = $prenom."\t".$nom."\t".$societe."\t".$email."\t".$telephone."\t".$autres."\r\n";
}
fwrite($myfile, $data);
fclose($myfile);
Hello @Pako69
I am looking at your code. I can see you have most likely a typo there. Given code like this:
$data = json_decode(file_get_contents('php://input'));
$infos = $data->form_response;
And you are trying to access this:
$infos->event_id
$infos->form_response->definition->title
However you should access it on $data
variable like this:
$data->event_id
$data->form_response->definition->title
Hi
(excuse my bad englishn I’m French)
I solved my issue ;)
I voluntarily separate the results from the other informations to make it easier for me, so the first one is of course:
$data = json_decode(file_get_contents('php://input'));
But then I put my datas in two different array :
Global informations into $infos:
$infos = $data->form_response;
And the Answers into $answers:
$answers = $data->form_response->answers;
So to access to the data of the array global informations, I now do this:
$submitted_at = $infos->submitted_at;
$token = $infos->token;
$autres = 'Titre du formulaire TypeForm : '.utf8_decode($infos->definition->title).' | ';
$bu = utf8_decode($infos->hidden->bu);
$formulaire = utf8_decode($infos->hidden->formulaire);
And it works like a charm ;)
Thanks for you help!