by Noora C.
I just got this working today. You need to first call the function you mentioned 'core_course_get_contents' to get the id's of each section/topic within the course.
Once you get the sectionid of of the section/topic you need to update, create an array (assuming you're using PHP). If you're changing the topic title, do something like this:
$temp = array();
$temp['component'] = 'format_topics'; // If the course is formatted using topics
$temp['itemtype'] = 'sectionname';
$temp['itemid'] = [THE_ITEM_ID]; // the section id returned by the core_course_get_contents function
$temp['value'] = [YOUR_NEW_TITLE]; // can't be an empty string, or it won't update
Then just end the above array over and it should update the topic title.