Custom code that sets custom field value stopped working in 4.6
I don't believe that the document you referenced is current best practice - it should probably be rewritten!  Using the BAO rather than the API to set values greatly increases the chance that an upgrade will break someone's custom extension.

You can troubleshoot the BAO code.  There's certainly something that could be done to make it work (assuming the issue is the code, and not that the hook is no longer firing).  However, I'd suggest rewriting the BAO call as an API call instead.  Something like this (assuming the custom field is attached to a Contact entity, otherwise change appropriately):

$params = array(
  'version' =&gt; 3,
  'custom_133' =&gt; 'foo',
  'id' =&gt; 1202,
);
$result = civicrm_api('Contact', 'create', $params);