How can I retrieve the value of a field in a flagging? I have a global flag, spam, that has a textfield, reason, attached to it. 

According to the Flag API documentation, I know I can check whether a user is flagged like this:

$spam &amp;&amp; $spam-&gt;is_flagged($account-&gt;uid)


However, in this case, I want to retrieve the flagging, and then check the value of a field in that flagging.  I didn't see any directions for doing so in the documentation, so I'm at a loss about how best to proceed.
According to the Flag API

flagging_load


  Loads a flagging entity. Parameters
  
  $flagging_id: The 'flagging_id' database serial column.
  
  $reset: Whether to reset the DrupalDefaultEntityController cache.
  Return value
  
  The entity object, or FALSE if it can't be found


Therefore something like this might work:

$flaggings = flag_get_user_flags('node', $node-&gt;nid);
if (isset($flaggings['spam'])) {
    $flagging = flagging_load($flaggings['spam']-&gt;flagging_id);
}


You will then find your field in:

$flagging-&gt;field_reason