<?php
//--- GET
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://url-de-la-api/test?param1=value');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
//echo $data;
?>
<?php
//--- POST
$fields = array('field1' => 'valor1', 'field2' => urlencode('valor 2'));
$fields_string = http_build_query($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://url-de-la-web/test");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string );
$data = curl_exec($ch);
curl_close($ch);
?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.