Любая помощь очень важна. приветствуется.
Захват HTTP-запроса POST:

Код: Выделить всё
add_action( 'rest_api_init', 'register_api_hooks' );
function register_api_hooks() {
register_rest_route( 'ep-to-zoho-crm/v1', '/updatecompany', array(
'methods' => 'POST',
'callback' => 'webhook_listener',
));
};
function webhook_listener($request){
// We don't want to process if it did not come from webhook
//if( !isset( $_GET['companyid'] ) ) { return; }
//$data = $request->get_param( 'companyid' );
if ( isset( $_REQUEST['companyid'] ) ) {
file_put_contents(plugin_dir_path( __FILE__ ).'crm.txt', 'works');
}else{
file_put_contents(plugin_dir_path( __FILE__ ).'invalid.txt', 'invalid');
}
/*$data = $_POST['companyid'];
file_put_contents(plugin_dir_path( __FILE__ ).'crm.txt', $data);
$json_string = json_encode($_POST);
$save = file_put_contents(plugin_dir_path( __FILE__ ).'crm.json', $json_string);*/
}
add_action( 'init', 'webhook_listener' );
Подробнее здесь: https://stackoverflow.com/questions/522 ... -urlencode
Мобильная версия