问题
I am getting the value of $mc_out with the below code:
<input type="text" id="input"><?php $mc_out = '<span style="display:none;">oninput:</span> <span
id="result"></span>' ;?>
<script>
input.oninput = function() {
result.innerHTML = input.value;
};
</script>
Now i am using this variable $mc_out in my api to get value dynamically. $mc_out value is changing everytime i change the value in form above but its not working in the below api without refresh. And once the page refreshed then $mc_out will become empty unless i enter the value again in the form.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://test-api-dev.testurl.org/in_school/$mc_out",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $final_token"
),
));
$response = curl_exec($curl);
$data = json_decode($response, true);
print_r($data);
please help me with this problem.
来源:https://stackoverflow.com/questions/63009083/how-change-the-value-of-variable-in-api-url-dynamically-using-html-form