WordPress创建响应发布请求插件

How to create wordpress request post and response plugin: My idea:

url: www.example.com/apidata/

php:

function apidata()
{
   if($_POST['data']==1)
   {
      $data=array('status'=>1);
      echo json_encode($data);
   }
   else{
      $data=array('status'=>0);
      echo json_encode($data);
     }
}

I ask you to excuse me, I do not know English well

I am not sure if I understand your question correctly - but here goes

You probably want to look at existing wordpress plugins first.

  1. You probably find most of what you want already exists
  2. or - you'll get an existing plugin that shows how to solve your own problem

Try to look at e.g. https://wordpress.org/plugins/json-api/