function pushToTwitter() { $post = grabPost(); $shortLink = shortenUrl(get_permalink($post->ID)); $ckey = get_option('tw_consumer_key'); $csecret = get_option('tw_consumer_secret'); $atoken = get_option('tw_access_token'); $asecret = get_option('tw_access_secret'); # Make our post to twitter based on our post content $twitterObj = new EpiTwitter($ckey, $csecret, $atoken, $asecret); $twitterObj->useAsynchronous(); $status = $twitterObj->post('/statuses/update.json', array('status' => trimPostForTwitter($post, $shortLink))); }
function tw_send($consumer_key, $consumer_secret, $token, $secret, $msg) { try { $twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret); //$a[0], $a[1], $a[2], $a[3]); $arr = splitText($msg, ' ', 140); $i = count($arr) - 1; while ($i >= 0) { $status = $twitterObj->post('/statuses/update.json', array('status' => $arr[$i])); $i--; } // echo post sent successfully //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>New post was sent to Twitter'); } catch (Exception $e) { // save error //em_save_post_error($id, $_SESSION['user'], $e->getMessage()); // echo error //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>Twitter error:'.$e->getMessage()); } }
global $listeners; global $current_song; // check your XML stream from sc_serv for the tags available to you // im just using current listeners and current song title if ($curTag == "^SHOUTCASTSERVER^CURRENTLISTENERS") { $listeners = $data; } if ($curTag == "^SHOUTCASTSERVER^SONGTITLE") { $current_song = $data; } } // control for parsing xml data $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); xml_parse($xml_parser, $xml); xml_parser_free($xml_parser); if ($refresh != "0") { print "<meta http-equiv=\"refresh\" content=\"{$refresh}\">\n"; } print "<title>{$current_song}</title>"; ?> <center> <?php // print "$tweet"; print "{$current_song}"; // tweet that shit $twitterObj->post('/statuses/update.json', array('status' => $current_song)); ?> </center>
<h2>Generate the authorization link</h2> <?php echo $twitterObjUnAuth->getAuthenticateUrl(); ?> <hr> <h2>Verify credentials</h2> <?php $creds = $twitterObj->get('/account/verify_credentials.json'); ?> <pre> <?php print_r($creds->response); ?> </pre> <hr> <h2>Post status</h2> <?php $status = $twitterObj->post('/statuses/update.json', array('status' => 'This a simple test from twitter-async at ' . date('m-d-Y h:i:s'))); ?> <pre> <?php print_r($status->response); ?> </pre> <script> function viewSource() { document.getElementById('source').style.display=document.getElementById('source').style.display=='block'?'none':'block'; } </script>
$to_push = trim($to_push); array_push($temp_array, $to_push); } } //sort our temp array into our ral array $radio_info['title'] = $temp_array[0]; $radio_info['description'] = $temp_array[1]; $radio_info['content_type'] = $temp_array[2]; $radio_info['mount_start'] = $temp_array[3]; $radio_info['bit_rate'] = $temp_array[4]; $radio_info['listeners'] = $temp_array[5]; $radio_info['most_listeners'] = $temp_array[6]; $radio_info['genre'] = $temp_array[7]; $radio_info['url'] = $temp_array[8]; $x = explode(" - ", $temp_array[9]); $radio_info['now_playing']['artist'] = $x[0]; $radio_info['now_playing']['track'] = $x[1]; ?> <?php foreach ($radio_info as $title => $data) { switch ($title) { case 'now_playing': print "{$data['artist']} - {$data['track']}"; // so you can see what the output looks like $twitterObj->post('/statuses/update.json', array('status' => $data[artist] . ' - ' . $data[track])); } } ?>
function twit_post_topic($msgOptions, $topicOptions, $posterOptions) { global $scripturl, $context, $smcFunc, $modSettings; tiwtt_get_boards2($topicOptions['board']); if (!empty($modSettings['tw_enpub'])) { if ($modSettings['tw_enpub'] == 2 || $modSettings['tw_enpub'] == 3) { if (!empty($modSettings['tw_app_enabled']) && !empty($context['pub_tw'])) { $consumer_key = !empty($modSettings['tw_app_id']) ? $modSettings['tw_app_id'] : ''; $consumer_secret = !empty($modSettings['tw_app_key']) ? $modSettings['tw_app_key'] : ''; $token = !empty($modSettings['tw_app_token']) ? $modSettings['tw_app_token'] : ''; $secret = !empty($modSettings['tw_app_tokensecret']) ? $modSettings['tw_app_tokensecret'] : ''; $to = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret); $req1 = $smcFunc['db_query']('', ' SELECT name FROM {db_prefix}boards WHERE id_board = {string:current_board}', array('one' => 1, 'current_board' => $topicOptions['board'])); $row = $smcFunc['db_fetch_assoc']($req1); $result = $row['name']; $smcFunc['db_free_result']($req1); $hash = strtolower(str_replace(' ', '_', $result)); $twtmessage = utf8_decode($msgOptions['subject']); $twturl = $scripturl . '?topic=' . $topicOptions['id'] . '.0'; if (!empty($modSettings['tw_app_shorturl']) && !empty($modSettings['tw_app_bituname']) && !empty($modSettings['tw_app_bitkey'])) { $newtwturl = tw_shorten($twturl, $modSettings['tw_app_bituname'], $modSettings['tw_app_bitkey']); } else { $newtwturl = $twturl; } $message = $twtmessage . ' ' . $newtwturl . ' #' . $hash; try { //Try it!!!!! $status = $to->post('/statuses/update.json', array('status' => utf8_encode($message))); } catch (EpiTwitterException $e) { //Catch it!!!!! return; //On EpiTwitterException error just return } catch (EpiTwitterForbiddenException $e) { //Catch it!!!!! return; //On EpiTwitterForbiddenException error just return } } else { return; //not enabled just return } } else { return; //not publishing this just return } } else { return; //not publishing this just return } }
include 'EpiOAuth.php'; include 'EpiTwitter.php'; include 'secret.php'; $twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $_COOKIE['oauth_token'], $_COOKIE['oauth_token_secret']); extract($_REQUEST); $url="1/statuses/retweet"; $link="$url/$id.json"; $creds = $twitterObj->post($link); $result = "$creds->responseText"; if($result=="{\"errors\":\"Share sharing is not permissable for this status (Share validations failed)\"}") { echo "error"; } else { echo "Retweet Success"; }
$info = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info); $info = str_replace('</body></html>', "", $info); $stats = explode(',', $info); if (empty($stats[1])) { $listeners[$i] = "0"; $msg[$i] = "<span class=\"red\">ERROR [There is no source connected]</span>"; $error[$i] = "1"; } else { if ($stats[1] == "1") { $song[$i] = $stats[6]; $listeners[$i] = $stats[4]; $max[$i] = $stats[3]; if ($stats[0] == $max[$i]) { $msg[$i] .= "<span class=\"red\">"; } if ($stats[0] == $max[$i]) { $msg[$i] .= "</span>"; } } else { $listeners[$i] = "0"; $msg[$i] = " <span class=\"red\">ERROR [Cannot get info from server]</span>"; $error[$i] = "1"; } } } $i++; } print "{$song['1']}"; // so you can see what the output looks like $twitterObj->post('/statuses/update.json', array('status' => $song[1])); // Tweet that shit.
function post_tweet($tweet) { $twitter_obj = new EpiTwitter($this->consumer_key, $this->consumer_secret); $twitter_obj->setToken($this->session->userdata('oauth_token'), $this->session->userdata('oauth_token_secret')); if ($twitter_obj->post('/statuses/update.json', array('status' => $tweet))) { return TRUE; } else { return FALSE; } }