In WordPress whenever new blog post is created all post details need to be send to third party API. I'm using save_post hook for this but not sure whether it's getting called or not This is what I've done so far
add_action( 'save_post', 'new_blog_details_send');
function new_blog_details_send( $post_id ) {
//getting blog post details//
$blog_title = get_the_title( $post_id );
$blog_link = get_permalink( $post_id );
$blog_text = get_post_field('post_content', $post_id);
///Sending data to portal////
$post_url = 'http://example.com/blog_update';
$body = array(
'blog_title' => $blog_title,
'blog_link' => $blog_link,
'blog_text' => $blog_text
);
//error_log($body);
$request = new WP_Http();
$response = $request->post( $post_url, array( 'body' => $body ) );
}
Not sure how to log or debug in WordPress. Any help would be appreciated. Thanks in advance.