function PostImage()
 {
     if (!isset($_POST['source']) || $_POST['source'] == "") {
         return "Missing required params";
     }
     $config = (include "/config.php");
     $source = $_POST['source'];
     $final = "";
     if (isset($_POST['message'])) {
         $orig = $_POST['message'];
         $final = FilterText($orig);
     }
     $access_token = $_SESSION['access_token'];
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
     $check = new TB_Twitter_Check();
     if (!$check->VerifyTweet($source, $final)) {
         return "Tweet is not valid";
         exit;
     }
     $media1 = $connection->upload('media/upload', array('media' => $source));
     $parameters = array('status' => $final, 'media_ids' => implode(',', array($media1->media_id_string)));
     $result = $connection->post('statuses/update', $parameters);
     if ($connection->getLastHttpCode() == 200) {
         return "success";
     } else {
         return "An unnknown error occured";
     }
 }
 function GenerateTweetIntent()
 {
     if (!isset($_POST['message'])) {
         return "Missing required params";
         exit;
     }
     $message = FilterText($_POST['message']);
     $check = new TB_Twitter_Check();
     if (!$check->VerifyTweet($message)) {
         return "Tweet is not valid";
         exit;
     }
     $url = "https://twitter.com/intent/tweet?text=" . $message;
     if (isset($_POST['url']) && $_POST['url'] != "") {
         $url .= "&url=" . $_POST['url'];
     }
     if (isset($_POST['hashtags']) && $_POST['hashtags'] != "") {
         $url .= "&hashtags=" . $_POST['hashtags'];
     }
     if (isset($_POST['via']) && $_POST['via'] != "") {
         $url .= "&via=" . $_POST['via'];
     }
     return $url;
 }