cURL POSTFIELDS mais avec variable $_GET
Bonjour a vous.
Voila que je lance dans une petite fonction cURL chose que j'ai pas trop deja utilisé, jai un petit probleme quand je voudrais passer une variable dans le POSTFIELDS
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?php
function RCPASpec()
{
if (isset($_POST['Index'])) {
$index = $_POST['Index'];
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://localhost/Specific',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => '{ "Parameters": { "Categorie": "Shot", "Index": 2 }, "GenerateTransaction": true }',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
// echo $response;
curl_close($curl);
} |
j'aimerais changer la ligne :
Code:
CURLOPT_POSTFIELDS => '{ "Parameters": { "Categorie": "Shot", "Index": 2 }, "GenerateTransaction": true }',
le 2 de l'index par ma variable qui provient du Grandement merci de votre aide :)