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 CreateLinkPost() { $config = (include "/config.php"); $client = new Tumblr\API\Client($config['tumblr_consumer_key'], $config['tumblr_consumer_secret']); $client->setToken($_SESSION['tumblr_token'], $_SESSION['tumblr_secret']); if (!isset($_POST['url']) || $_POST['url'] == "") { return "Missing required param: url"; exit; } if (!isset($_POST['blogName']) || $_POST['blogName'] == "") { return "Missing required param: blogName"; exit; } $blogName = $_POST['blogName']; $data = array("type" => "link", "url" => $_POST['url']); if (isset($_POST['description']) && $_POST['description'] != "") { $data['description'] = FilterText($_POST['description']); } if (isset($_POST['thumbnail']) && $_POST['thumbnail'] != "") { $data['thumbnail'] = $_POST['thumbnail']; } if (isset($_POST['author']) && $_POST['author'] != "") { $data['author'] = FilterText($_POST['author']); } try { $client->createPost($blogName, $data); } catch (Exception $ex) { return "That blog does not exist"; } return "success"; }
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; }
function ConvertFromFormat($filedata) { global $SourceType, $RewrapParagraphs, $BreakOnChapter; if ($SourceType == 'Text') { if (!isset($RewrapParagraphs)) { $RewrapParagraphs = false; } return FilterText($filedata, $RewrapParagraphs); } if ($SourceType == 'HTML') { return FilterHtml($filedata); } if ($SourceType == 'Gutenberg') { if (!isset($BreakOnChapter)) { $BreakOnChapter = false; } return FilterGutenberg($filedata, $BreakOnChapter); } ShowError('Invalid source type.'); return false; }
function PostVideo() { if (!isset($_POST['source']) || $_POST['source'] == "") { return "Missing required param"; exit; } $config = (include "/config.php"); $fb = new Facebook\Facebook(['app_id' => $config['app_id'], 'app_secret' => $config['app_secret'], 'default_graph_version' => 'v2.4']); $data = ['source' => $fb->videoToUpload($_POST['source'])]; if (isset($_POST['description']) && $_POST['description'] != "") { $data['description'] = FilterText($_POST['description']); } if (isset($_POST['title']) && $_POST['title'] != "") { $data['title'] = FilterText($_POST['title']); } try { $response = $fb->post('/me/videos', $data, $_SESSION['facebook_access_token']); } catch (Facebook\Exceptions\FacebookResponseException $e) { // When Graph returns an error echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch (Facebook\Exceptions\FacebookSDKException $e) { // When validation fails or other local issues echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } return 'success'; }