How to create plugin auto create page wordpress?

The following hook is called when the plugin is activated from the dashboard.

register_activation_hook( __FILE__, 'myplugin_activate' );
function myplugin_activate() {
   //create a variable to specify the details of page
   $post = array(     
             'post_content'   => 'content', //content of page
             'post_title'     =>'title', //title of page
             'post_status'    =>  'publish' , //status of page - publish or draft
             'post_type'      =>  'page'  // type of post
   );
   wp_insert_post( $post ); // creates page
}