结果是I\'m trying to integrate witei\'s CRM into a website. 根据witei文件,I must indicate a url (webhook), 我想在哪里接收已更改属性的信息,以便我可以随时更新网站的属性。
信息通过POST method 服务之所以有效是因为it returns the data in JSON format, 通过测试https://beeceptor.com/ 服务(生成临时端点)。
事实上,根据我所阅读(或理解)的内容,我必须按照Wordpress文档中的步骤在Wordpress中创建端点:https://developer.wordpress.org/rest- api/扩展rest api/添加自定义端点/
我的问题是:我的方向正确吗?如果是这样。。。创建端点后,是否必须创建任何额外文件?或者只包含“register\\u rest\\u route”功能,不需要做任何其他事情?我尝试过按照指示操作,但总是出现错误404。
涉及的代码是://Testing webhook
add_action( \'rest_api_init\', function () {
register_rest_route( \'real-estate-lite/v1\', \'/endpoint\', array(
\'methods\' => \'POST\',
\'callback\' => \'my_awesome_func\',
) );
} );
function my_awesome_func( $request ) {
$data = $request->get_json_params();
error_log( print_r( $data, true ) );
}
在Witei CRM中,我得到了以下结果:有人能帮我吗?还是把我带到正确的方向?非常感谢。