besoin de votre aide sur celui-ci ... Comment convertir ces tableaux au code JSON ...Comment convertir tableau en JSON
voici mon code:
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
// Will dump a beauty json :3
//var_dump(json_decode($result, true));
//$result = file_get_contents($url);
// Will dump a beauty json :3
//var_dump(json_decode($result, true));
//write to json file
$ssim = array($result);
$fp = fopen('rsspb.json', 'w');
//have a backslashes remover
fwrite($fp, json_encode($ssim, JSON_UNESCAPED_SLASHES));
fclose($fp);
Voici le résultat:
["{\"tickets\":[{\"url\":\"https://51talk.zendesk.com/api/v2/tickets/1.json\",\"id\":1,\"external_id\":null,\"via\":{\"channel\":\"sample_ticket\",\"source\":{\"from\":{},\"to\":{},\"rel\":null}},\"created_at\":\"2017-04-25T05:56:36Z\",\"updated_at\":\"2017-04-25T05:56:36Z\",\"type\":\"incident\",\"subject\":\"Sample ticket: Meet the ticket\",\"raw_subject\":\"Sample ticket: Meet the ticket\",\"description\":\"Hi Noel,\\n\\nEmails, chats, voicemails, and tweets are captured in Zendesk Support as tickets. Start typing above to respond and click Submit to send. To test how an email becomes a ticket, send a message to [email protected]\\n\\nCurious about what your customers will see when you reply? Check out this video:\\nhttps://demos.zendesk.com/hc/en-
en utilisant json_encode ($ result)? La question n'est pas claire ... –
hmm ... ineed pour rendre les tableaux à json – ivor
Copie possible de [Convertir le tableau de résultats PHP en JSON] (https://stackoverflow.com/q/2122233/6521116) –