How to add points using User Points in Drupal 6
Check nodevote module. It does something similar. You may use it directly or base your code on it.

If you want to use a more sofisticated solution with VotingAPI you can use  userpoints_votingapi and use rate module for the widgets

Cheers.