-
-
Save dexit/553d8bec4ca867680f76aaff728f47c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'rest_api_init', 'custom_routes_webhook_0277'); | |
function custom_routes_webhook_0277(){ | |
//(exemplo: /wp-json/exemplo/notificacoes) | |
register_rest_route( | |
'exemplo', '/notificacoes/', array( | |
'methods' => 'POST', | |
'callback' => 'notificacoes_api', | |
'show_in_index' => false | |
) | |
); | |
} | |
function notificacoes_api(WP_REST_Request $request){ | |
// Obtendo os dados do POST | |
$data_received = $request->get_json_params(); | |
// Exemplo acessando dados | |
// $data_received['id'].... etc | |
return new WP_REST_Response(array( | |
'status' => 'sucesso' | |
), 200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment