How to add pages to custom menus on the fly [duplicate]

I guess it doesn’t need anymore explanation:

$mymenu = wp_get_nav_menu_object('Main Navigation Menu');
$menuID = (int) $mymenu->term_id;
$myPage = get_page_by_title('About Us');

$itemData =  array(
    'menu-item-object-id' => $myPage->ID,
    'menu-item-parent-id' => 0,
    'menu-item-position'  => 2,
    'menu-item-object' => 'page',
    'menu-item-type'      => 'post_type',
    'menu-item-status'    => 'publish'
  );

wp_update_nav_menu_item($menuID, 0, $itemData);

error code: 523