/**
  * 
  * @param PostController $Sender
  * @param type $RecordType
  * @param type $ID
  * @throws type
  */
 public function PostController_Twitter_Create($Sender, $RecordType, $ID)
 {
     if (!$this->SocialReactions()) {
         throw PermissionException();
     }
     //      if (!Gdn::Request()->IsPostBack())
     //         throw PermissionException('Javascript');
     $Row = GetRecord($RecordType, $ID);
     if ($Row) {
         // Grab the tweet message.
         switch (strtolower($RecordType)) {
             case 'discussion':
                 $Message = Gdn_Format::PlainText($Row['Name'], 'Text');
                 break;
             case 'comment':
             default:
                 $Message = Gdn_Format::PlainText($Row['Body'], $Row['Format']);
         }
         $Elips = '...';
         $Message = preg_replace('`\\s+`', ' ', $Message);
         //         if (function_exists('normalizer_is_normalized')) {
         //            // Slice the string to 119 characters (21 reservered for the url.
         //            if (!normalizer_is_normalized($Message))
         //               $Message = Normalizer::normalize($Message, Normalizer::FORM_D);
         //            $Elips = Normalizer::normalize($Elips, Normalizer::FORM_D);
         //         }
         $Max = 140;
         $LinkLen = 22;
         $Max -= $LinkLen;
         $Message = SliceParagraph($Message, $Max);
         if (strlen($Message) > $Max) {
             $Message = substr($Message, 0, $Max - strlen($Elips)) . $Elips;
         }
         //         echo $Message.strlen($Message);
         if ($this->AccessToken()) {
             Gdn::Controller()->SetData('Message', $Message);
             $Message .= ' ' . $Row['ShareUrl'];
             $R = $this->API('/statuses/update.json', array('status' => $Message), 'POST');
             $Sender->SetJson('R', $R);
             $Sender->InformMessage(T('Thanks for sharing!'));
         } else {
             $Get = array('text' => $Message, 'url' => $Row['ShareUrl']);
             $Url = "http://twitter.com/share?" . http_build_query($Get);
             Redirect($Url);
         }
     }
     $Sender->Render('Blank', 'Utility', 'Dashboard');
 }
 /**
  * 
  * @param PostController $Sender
  * @param type $RecordType
  * @param type $ID
  * @throws type
  */
 public function PostController_Facebook_Create($Sender, $RecordType, $ID)
 {
     if (!$this->SocialReactions()) {
         throw PermissionException();
     }
     //      if (!Gdn::Request()->IsPostBack())
     //         throw PermissionException('Javascript');
     $Row = GetRecord($RecordType, $ID);
     if ($Row) {
         $Message = SliceParagraph(Gdn_Format::PlainText($Row['Body'], $Row['Format']), 160);
         if ($this->AccessToken() && $Sender->Request->IsPostBack()) {
             $R = $this->API('/me/feed', array('link' => $Row['ShareUrl'], 'message' => $Message));
             $Sender->SetJson('R', $R);
             $Sender->InformMessage(T('Thanks for sharing!'));
         } else {
             //            http://www.facebook.com/dialog/feed?app_id=231546166870342&redirect_uri=http%3A%2F%2Fvanillicon.com%2Fredirect%2Ffacebook%3Fhash%3Daad66afb13105676dffa79bfe2b8595f&link=http%3A%2F%2Fvanillicon.com&picture=http%3A%2F%2Fvanillicon.com%2Faad66afb13105676dffa79bfe2b8595f.png&name=Vanillicon&caption=What%27s+Your+Vanillicon+Look+Like%3F&description=Vanillicons+are+unique+avatars+generated+by+your+name+or+email+that+are+free+to+make+%26+use+around+the+web.+Create+yours+now%21
             $Get = array('app_id' => C('Plugins.Facebook.ApplicationID'), 'link' => $Row['ShareUrl'], 'name' => Gdn_Format::PlainText($Row['Name'], 'Text'), 'description' => $Message, 'redirect_uri' => Url('/post/shared/facebook', TRUE));
             $Url = 'http://www.facebook.com/dialog/feed?' . http_build_query($Get);
             Redirect($Url);
         }
     }
     $Sender->Render('Blank', 'Utility', 'Dashboard');
 }