I create a URL on mantis with curl and I would like that when its execution it fills my "holliday" table in my DATA, i use an API for the holliday.
I created my function with my url but I am blocked to go further
function url
function get_url_holliday( $t_date, $t_label, $timeout = 30 ) {
$url = str_replace( "&", "&", urldecode(trim($url)) );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" );
curl_setopt( $ch, CURLOPT_URL, "https://calendrier.api.gouv.fr/jours-feries/metropole/2021.json" );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_ENCODING, "UTF-8" );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); # required for https urls
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
$content = curl_exec( $ch );
$response = curl_getinfo( $ch );
curl_close ( $ch );
var_dump($content);
die();
if ($response['http_code'] == 301 || $response['http_code'] == 302)
{
ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
if ( $headers = get_headers($response['url']) ) {
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
}
}
if (( preg_match("/>[[:space:]]+window.location.replace('(.*)')/i", $content, $value) || preg_match("/>[[:space:]]+window.location="(.*)"/i", $content, $value) ) && $javascript_loop < 5){
return get_url( $value[1], $javascript_loop+1 );
} else {
return array( $content, $response );
}
$request_type_table = plugin_table('data', 'AbChiffrage');
$t_query = 'INSERT INTO '.$t_table .' (date, label) VALUES ('.db_param().','.db_param().')';
db_query($t_query, array($t_date, $t_label));
}
My table
array( 'CreateTableSQL', array( plugin_table( 'hollidays'), "
date C(255) DEFAULT NULL,
label C(255) DEFAULT NULL
")
),
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…