I have made acreated this simple WordPress REST API where user calls this URLusers can perform:
Option A
• Types in the following URL in browser:
→
www.example.com/wp-json/v1/getBook/123456?AuthorSurname=Buckley
The responseAPI will retrieve the relevant information and return a response in the browser:
→
{"Book":"Thank you for smoking"}
in browser.
Option B
I• Perform a CURL statement in CMD or via scripting:
(for Example)
function getBook($authorID, $authorSurname){
$ch = curl_init();
$url = 'www.example.com/wp-json/v1/getBook/123456?AuthorSurname=Buckley';
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:application/json','Content-Type:application/json' ));
curl_setopt($ch, CURLOPT_URL, $url.$authorID.'?AuthorSurname='.$authorSurname);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute the POST request
$result = curl_exec($ch);
return $result;
curl_close($ch);
<br><br>
I would like to hideprevent the response / replace it with another pagefrom showing whenever user keys in this URLperform Option A.
The response can only be shown when it is triggered by CURL postvia Option B.
How can I achieve this?