There are some options with the Twitter Autopost control which will do this automatically for you. Are you checking the box to "Create a tweet when you save the page" AS WELL AS setting either a "Publish time" or checking the "Post tweet after page is published" box and setting a "Publish from" date?
There should be no reason to write code around this functionality as it already exists. Also, from what I've looked at there isn't a scheduled task to publish or post to Twitter in v8, so maybe that was some remnant of a v7 upgrade?