I'd like to send the following cURL statement from my website to my site's API:
curl -X GET https://mywebsite.com/api/v1/clients?id_number=<value> -H "Token: TOKEN"
Where id_number value comes from a HTML standard form like this:
<form action="somethinghere" method="post" target="_blank">
<input type="text" name="id_number">
<input type="submit" value="Submit">
</form>
Any idea will be appreciated..
Regards,
As you are using POST
to submit your HTML form so Get id_number
from POST
Params on PHP
page and add cURL
code like this:
$id_number = $_POST['id_number'];
//Server url
$url = "https://mywebsite.com/api/v1/clients?id_number=".$id_number;
// declare your token here
// OR define a constant at the top of file like define('TOKEN', 'value of token');
$token = '';
$headers = array(
'Token: '.$token
);
// Send request to Server
$ch = curl_init($url);
// To save response in a variable from server, set headers;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Get response
$response = curl_exec($ch);
// print response
print_r($response);