plugins - Hide response returned from WordPress REST API call

I have created this simple WordPress REST API where users can perform:Option A• Types in the following URL in browser

I have created this simple WordPress REST API where users can perform:

  Option A
• Types in the following URL in browser:
      → www.example/wp-json/v1/getBook/123456?AuthorSurname=Buckley
   The API will retrieve the relevant information and return a response in the browser:
      → {"Book":"Thank you for smoking"}

  Option B
• Perform a CURL statement in CMD or via scripting:
   (for Example)

function getBook($authorID, $authorSurname){  
    $ch = curl_init();
    $url = 'www.example/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 prevent the response from showing whenever user perform Option A.
The response can only be shown via Option B.

How can I achieve this?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744882206a4598903.html

相关推荐

  • plugins - Hide response returned from WordPress REST API call

    I have created this simple WordPress REST API where users can perform:Option A• Types in the following URL in browser

    2天前
    80

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信