コード例 #1
0
 function restPublishStream()
 {
     $fbuid = $this->flink->foreign_id;
     common_debug(sprintf('Attempting to post notice %d as stream item for %s (%d) fbuid %d', $this->notice->id, $this->user->nickname, $this->user->id, $fbuid), __FILE__);
     $fbattachment = $this->formatAttachments();
     $result = $this->facebook->api(array('method' => 'stream.publish', 'message' => $this->formatMessage(), 'attachment' => $fbattachment, 'uid' => $fbuid));
     if (!empty($result)) {
         // result will contain the item ID
         // Save a mapping
         Notice_to_item::saveNew($this->notice->id, $result);
         common_log(LOG_INFO, sprintf('Posted notice %d as a %s for %s (%d), fbuid %d', $this->notice->id, empty($fbattachment) ? 'stream item' : 'stream item with attachment', $this->user->nickname, $this->user->id, $fbuid), __FILE__);
     } else {
         $msg = sprintf('Could not post notice %d as a %s for %s (%d), fbuid %d - error code: %s', $this->notice->id, empty($fbattachment) ? 'stream item' : 'stream item with attachment', $this->user->nickname, $this->user->id, $result, $fbuid);
         throw new FacebookApiException($msg, $result);
     }
 }