'curl', 'label' => 'Lancer une requête', 'class' => get_called_class(), 'path' => __FILE__, 'icon' => 'fas fa-atlas', 'color' => '#ff9f43', ); if(!isset($key)) return $manifest; return isset($manifest[$key]) ? $manifest[$key] : '' ; } //méthode d'affichage de l'effet public static function form($item){ $html = ''; $class = get_called_class(); ob_start(); ?>
Méthode
URL
En-têtes Corps
Format de résultat
Variable de résultat
Prendre le chemin JSON
toArray(); if(isset($parameters['old'])) $parameters['old'] = $parameters['old']->toArray(); } $effect->values['curl-method'] = template($effect->values['curl-method'],$parameters,true); $effect->values['curl-url'] = template($effect->values['curl-url'],$parameters,true); $effect->values['curl-header'] = template($effect->values['curl-header'],$parameters,true); $effect->values['curl-body'] = template($effect->values['curl-body'],$parameters,true); $ch = curl_init(); $options = array( CURLOPT_URL => $effect->values['curl-url'], CURLOPT_HEADER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT=> 10000 ); $options[CURLOPT_HTTPHEADER] = explode(PHP_EOL,$effect->values['curl-header']); $options[CURLOPT_POSTFIELDS] = $effect->values['curl-body'] ; curl_setopt_array($ch, $options); $logs .= ' Lancement de la requete '.$effect->values['curl-method'].' '.$effect->values['curl-url'].'
'; $results = curl_exec($ch); $logs .= 'Résultat '.$results.'
'; curl_close($ch); if(isset($effect->values['curl-var'])){ $logs .= 'Stockage résultat en variable '.$effect->values['curl-var'].'
'; if($effect->values['curl-result-type'] == 'json'){ $results = json_decode($results,true); $logs .= 'Décodage json :'.($results==false?'JSON incorrect':'JSON correct').'
'; if(!empty($effect->values['curl-var-path']) && $results!=false){ foreach (explode('.',$effect->values['curl-var-path']) as $key => $value) { if(!isset($results[$value])) break; $results = $results[$value]; } } } $logs .= 'Stokage résultat '.$effect->values['curl-var'].' = '.$results.'
'; $workflowVars = json_decode($conf->get('workflow-var'),true); $workflowVars[$effect->values['curl-var']] = $results; $conf->put('workflow-var', json_encode($workflowVars)); } return $logs; } } ?>