send() public method

Sends message to the Twitter.
public send ( $message, $media = NULL ) : stdClass
return stdClass see https://dev.twitter.com/rest/reference/post/statuses/update
function post_to_twitter($message)
{
    # These keys are for the @playbitfighter twitter account.
    # Log in and go to https://apps.twitter.com/ to manage them
    $consumerKey = "REPLACEME";
    $consumerSecret = "REPLACEME";
    $accessToken = "REPLACEME";
    $accessTokenSecret = "REPLACEME";
    $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
    $twitter->send($message);
}
 protected function sendNowPlaying()
 {
     $track = $this->track_to_notify;
     $message = $this->msg_format;
     foreach ($this->message_filters as $mf) {
         /* @var $mf ITrackMessageFilter */
         $message = $mf->apply($track, $message);
     }
     // Twitter max message length, minus the pre-processed message,
     // and give back 2 chars for '%s'
     $max_title_length = 160 - (mb_strlen($message) - 2);
     $title = $track->getFullTitle();
     $title_length = mb_strlen($title);
     if ($title_length > $max_title_length) {
         $title = mb_substr($title, 0, $this->max_title_length - 1) . '…';
     }
     $status = sprintf($message, $title);
     try {
         L::level(L::DEBUG) && L::log(L::DEBUG, __CLASS__, 'Sending Now Playing to Twitter', array());
         $this->twitter->send($status);
     } catch (Exception $e) {
         L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Could not send Now Playing to Twitter: %s', array($e->getMessage()));
     }
 }
Beispiel #3
0
 /**
  * @param string $message
  */
 public static function sendMessage($message)
 {
     global $consumerKey, $consumerSecret, $accessToken, $accessTokenSecret;
     $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
     return $twitter->send($message);
 }
Beispiel #4
0
<?php

require_once '../twitter.class.php';
// ENTER HERE YOUR CREDENTIALS (see readme.txt)
$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$status = $twitter->send('I am fine');
echo $status ? 'OK' : 'ERROR';
Beispiel #5
0
function SendTopPickTwits($debug)
{
    global $hd;
    global $config;
    $default = 0;
    $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (1 - $default), date("Y"));
    $LocalTime = localtime();
    if ($LocalTime[2] < 6) {
        $Today = $Yesterday;
        $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (2 - $default), date("Y"));
    } else {
        $Today = mktime(0, 0, 0, date("m"), date("d") - $default, date("Y"));
    }
    $ThisDate = date("Y-m-d", $Today);
    $qq = "select *,New_opinion.id as Oid, New_company.name as CompanyName from New_opinion,New_company,New_expert where\n\t\tNew_opinion.company_id = New_company.id and \n\t\tNew_opinion.expert_id=New_expert.id and  New_opinion.signal_id=16 and New_opinion.Date=\"{$ThisDate}\"";
    /*$qq = "select *,New_opinion.id as Oid, New_company.name as CompanyName from New_opinion,New_company,New_expert where
    		New_opinion.company_id = New_company.id and 
    		New_opinion.expert_id=New_expert.id and  New_opinion.signal_id=16 and New_opinion.Date=\"2016-04-11\"";
    */
    // New_opinion.signal_id==3 is comment
    // New_opinion.signal_id==3 is comment
    if ($debug) {
        echo "Query is <br>{$qq}<br>";
    }
    $result1 = $hd->query($qq);
    //	print_r($hd->errorInfo());
    $NumAlerts = $result1->rowCount();
    //($result1);
    //	print_r($hd->errorInfo());
    echo "Number of alerts is {$NumAlerts}<br>";
    if ($debug) {
        echo '<br>Debug';
    }
    for ($an = 0; $an < $NumAlerts; $an++) {
        $row1 = $result1->fetch();
        //$result1);
        //			foreach ($row1 as $key => $ra)
        //				echo  "<br>$key is $ra";
        //$cl = slink('http://www.stockchase.com/Company?ID='. $row1['company'],'','','','',$row1['company']);
        $cl = '#stockaction #' . $row1['symbol'] . ' http://www.stockchase.com';
        $companyline = 'http://www.stockchase.com/company/view/' . $row1['company_id'] . '/' . $row1['Oid'];
        if ($debug) {
            echo '<br>' . $companyline;
        }
        $companyline = getBitUrl($companyline);
        $companyname = $row1['CompanyName'];
        if (strlen($companyname > 10)) {
            $companyname = substr($companyname, 0, 7);
            $companyname .= '...';
        }
        $companyname = str_replace(" ", "-", $companyname);
        if ($row1['CompanyName'] == $companyname) {
            $companyname = "@" . $companyname;
        }
        $cl = $companyname . ' ' . $companyline . ' #stocks $' . $row1['symbol'];
        $symbol = $row1['symbol'];
        //			$cl = 'http://www.stockchase.com/Opinion.php';
        //			$cl = 'http://tinyurl.com/5dqmwd';
        $twitterStatus = strip_tags($row1['comment']);
        $twitterStatus = str_replace('&nbsp', ' ', $twitterStatus);
        $twitterStatus = str_replace(';', ' ', $twitterStatus);
        $twitterStatus = str_replace(' are ', ' r ', $twitterStatus);
        $twitterStatus = str_replace(' wait ', ' W8 ', $twitterStatus);
        $twitterStatus = str_replace(' ate ', ' 8 ', $twitterStatus);
        $twitterStatus = str_replace(' late ', ' L8 ', $twitterStatus);
        $twitterStatus = str_replace('  ', ' ', $twitterStatus);
        if (strlen($twitterStatus . $cl) >= 129) {
            $twitterStatus1 = substr($twitterStatus, 0, 126 - strlen($cl));
            $twitterStatus = $twitterStatus1 . "...";
        }
        $twitterStatus .= $cl;
        echo '<br>
';
        echo $twitterStatus;
        echo '
';
        if ($debug) {
            echo "<br>{$an} Would send to twitter <b>{$twitterStatus}</b>";
        } else {
            try {
                $twitter = new Twitter($config['consumer_key'], $config['consumer_secret'], $config['access_token'], $config['access_token_secret']);
                $twitter->send($twitterStatus);
            } catch (Exception $e) {
                echo 'Caught Exception: ', $e->getMessage(), '\\n';
                //	mail('*****@*****.**','stockchase twitter error');
                //die('here');
            }
            //echo shell_exec('/home/stockchase/EditorFunctions/python/mytweet.py "'. $twitterStatus. '"');
            flush();
            sleep(5);
        }
        $tocompany = $companyname . " is Top Pick at StockChase http://www.stockchase.com/opinions/recent #stockaction \$" . $symbol;
        echo '<br>
' . $tocompany . '
';
        if ($debug) {
            echo "<br>{$an} Would send to twitter <b>{$tocompany}</b>";
        } else {
            try {
                $twitter = new Twitter($config['consumer_key'], $config['consumer_secret'], $config['access_token'], $config['access_token_secret']);
                $twitter->send($tocompany);
            } catch (Exception $e) {
                echo 'Caught Exception: ', $e->getMessage(), '\\n';
                //	mail('*****@*****.**','stockchase twitter error company');
                //die('here');
            }
            //echo shell_exec('/home/stockchase/EditorFunctions/python/mytweet.py "', $tocompany. '"');
            flush();
            sleep(10);
        }
    }
}
/**
 * Post a message to a twitter feed.
 *
 */
function twitterservice_send($twittername, $twitterpass, $twittermessage)
{
    $twitter = new Twitter($twittername, $twitterpass);
    return $twitter->send($twittermessage);
}
Beispiel #7
0
<?php

require_once '../src/twitter.class.php';
// ENTER HERE YOUR CREDENTIALS (see readme.txt)
$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
try {
    $tweet = $twitter->send('I am fine');
    // you can add $imagePath as second argument
} catch (TwitterException $e) {
    echo 'Error: ' . $e->getMessage();
}
Beispiel #8
0
<?php

require '../common/globals.php';
require '../common/twitter-php-3.2/src/twitter.class.php';
// Fill in the next 2 variables.
$access_token = '15201275-loypZtq58TRB1qoIIu6fTw6TSEqluGZ1aMKgVJjJe';
$access_token_secret = 'haKjTuzH9N6UPhOBZDKSsu6FAZzIvLNbwGhi5wfy00Y';
$twitter = new Twitter(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $access_token, $access_token_secret);
$message = $_GET['message'];
try {
    $twitter->send($message);
    echo "\n\n\n\n";
} catch (TwitterException $e) {
    echo "Error posting status update to Twitter: ", $e->getMessage();
}
?>

Beispiel #9
0
 if ($sellQuantity > 0) {
     $itemFee = $item->marketprice / 100 * $auctionFee * $sellQuantity;
     if ($player->money >= $itemFee) {
         $item->changeQuantity(0 - $sellQuantity);
         $timeNow = time();
         $player->spend($itemFee, $useMySQLiConomy, $iConTableName);
         $itemQuery = mysql_query("INSERT INTO WA_Auctions (name, damage, player, quantity, price, created, allowBids, currentBid, currentWinner) VALUES ('{$item->name}', '{$item->damage}', '{$item->owner}', '{$sellQuantity}', '{$sellPrice}', '{$timeNow}', '{$allowBids}', '{$minBid}', '{$item->owner}')");
         $queryLatestAuction = mysql_query("SELECT id FROM WA_Auctions ORDER BY id DESC");
         list($latestId) = mysql_fetch_row($queryLatestAuction);
         if ($item->quantity == 0) {
             $item->delete();
         }
         if ($useTwitter == true) {
             try {
                 $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
                 $twitter->send('[WA] Auction Created: ' . $user . ' is selling ' . $sellQuantity . ' x ' . $itemFullName . ' for ' . $currencyPrefix . $sellPrice . $currencyPostfix . ' each. At ' . date("H:i:s") . '. ' . $shortLinkToAuction . ' #webauction');
             } catch (Exception $e) {
                 //normally means you reached the daily twitter limit.
             }
         }
         $queryEnchants = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId='{$item->id}' AND itemTableId ='0'");
         while (list($idk, $enchIdk, $tableIdk, $itemIdk) = mysql_fetch_row($queryEnchants)) {
             $updateEnch = mysql_query("INSERT INTO WA_EnchantLinks (enchId, itemTableId, itemId) VALUES ('{$enchIdk}', '1', '{$latestId}')");
         }
         $_SESSION['success'] = str_replace(array('#sellQuantity#', '#itemFullName#', '#sellPrice#', '#itemFee#'), array($sellQuantity, $itemFullName, $currencyPrefix . $sellPrice . $currencyPostfix, $currencyPrefix . $itemFee . $currencyPostfix), $lang['newAuction']['success']);
         header("Location: ../myauctions.php");
     } else {
         $_SESSION['error'] = str_replace('#itemFee#', $currencyPrefix . $itemFee . $currencyPostfix, $lang['newAuction']['error']);
         header("Location: ../myauctions.php");
     }
 } else {
Beispiel #10
0
<?php

require_once 'twitter.class.php';
$twitter = new Twitter('pokusnyucet2', '123456');
$status = $twitter->send('Mám se fajn II');
echo $status ? 'OK' : 'ERROR';
Beispiel #11
0
// fecha y hora
$time = date('H:i:s');
$dir = date('Y/m/d');
$file = date('His') . '.txt';
// rutas y url
$path_dir = implode('/', array($log, $dir));
$path_file = implode('/', array($path_dir, $file));
$url = implode('/', array($base, $dir, $file));
// guardamos mensaje same
if (!is_dir($path_dir)) {
    mkdir($path_dir, 0755, true);
}
file_put_contents($path_file, $txt . "\n");
// examinamos mensaje same
if (preg_match('/-([A-Z]{3})-([A-Z]{3})-([0-9]{6})\\+([0-9]{4})-([0-9]{7})-(.{8})-/i', $txt, $match)) {
    // construimos mensaje twitter
    $msg = '';
    if ($match[2] == 'RWT') {
        $msg = 'Prueba periódica @ ' . $time;
    } else {
        if ($match[2] == 'EQW') {
            $msg = 'ALERTA SÍSMICA @ ' . $time;
        } else {
            $msg = 'Mensaje desconocido @ ' . $time;
        }
    }
    $msg .= ', mensaje original: ' . $url;
    // publicamos mensaje en twitter
    $twitter = new Twitter($consumer_key, $consumer_secret, $access_token, $access_token_secret);
    $tweet = $twitter->send($msg);
}
Beispiel #12
0
<?php

require_once '../src/twitter.class.php';
// ENTER HERE YOUR CREDENTIALS (see readme.txt)
$consumerKey = "NKqsayp5CblGxyTwMAtLTjynM";
$consumerSecret = "7Lq8HiP1gi7QYW93gvLNXAYV4eeISLLpull0bhOW6mH6TWSnam";
$accessToken = "276740008-7Tva3cvpI7NXJFT8ycgIkVjELJv5l23CDvJenmYE";
$accessTokenSecret = "5tMkO9Bg33o9oQVKPagrb0yXFbORNtGTABHTabwjVKPhr";
$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$userTweet = $_POST["userTweet"];
try {
    $tweet = $twitter->send($userTweet);
    // you can add $imagePath as second argument
} catch (TwitterException $e) {
    echo 'Error: ' . $e->getMessage();
}
?>

<html>
<head>
    <title>HyTweet</title>
    <meta http-equiv="refresh" content="1; url=index.php" />
</head>
<body>
    <center>
        <br><br>
        <h1>Tweet Sent!</h1>
            <h4>You are now being redirected back to the homepage.</h4>
    </center>
</body>
</html>
Beispiel #13
0
    list($date, $text) = explode("\t", $line);
    $data[] = ['date' => Carbon::createFromFormat('Y/m/d H:i:s', $date, "Asia/Tokyo"), 'text' => $text];
}
// Check least execute datetime.
$date_needle_file_path = __DIR__ . '/last_run_time.txt';
try {
    if (!file_exists($date_needle_file_path)) {
        file_put_contents($date_needle_file_path, '0');
    }
    $date_needle = file_get_contents($date_needle_file_path);
} catch (\Exception $e) {
    $log->error($e->getMessage());
    var_dump($e->getMessage());
    exit;
}
$last_date = Carbon::createFromTimestamp($date_needle);
// update last execute time.
file_put_contents($date_needle_file_path, time());
// create Twitter client.
include __DIR__ . '/config.php';
$t = new \Twitter($token[0], $token[1], $token[2], $token[3]);
// read data.tsv and post tweet.
$now = Carbon::create();
foreach ($data as $item) {
    $item_date = $item['date'];
    if ($item_date < $now && $item_date > $last_date) {
        $log->info("tweet:" . $item['text'] . "\n");
        $t->send($item['text']);
    }
}
$log->debug('done');
Beispiel #14
0
     if ($base > 0) {
         $newMarketPrice = $newMarketPrice / ($base - $itemDamage) * $base;
         $insertMarketPrice = mysql_query("INSERT INTO WA_MarketPrices (name, damage, time, marketprice, ref) VALUES ('{$auction->name}', '0', '{$timeNow}', '{$newMarketPrice}', '{$marketCount}')");
         $queryLatestAuction = mysql_query("SELECT id FROM WA_MarketPrices ORDER BY id DESC");
         list($latestId) = mysql_fetch_row($queryLatestAuction);
         $queryEnchants = mysql_query("SELECT * FROM WA_EnchantLinks WHERE itemId='{$auction->id}' AND itemTableId ='1'");
         while (list($idk, $enchIdk, $tableIdk, $itemIdk) = mysql_fetch_row($queryEnchants)) {
             $updateEnch = mysql_query("INSERT INTO WA_EnchantLinks (enchId, itemTableId, itemId) VALUES ('{$enchIdk}', '4', '{$latestId}')");
         }
     } else {
         $insertMarketPrice = mysql_query("INSERT INTO WA_MarketPrices (name, damage, time, marketprice, ref) VALUES ('{$auction->name}', '{$auction->damage}', '{$timeNow}', '{$newMarketPrice}', '{$marketCount}')");
     }
     if ($useTwitter == true) {
         try {
             $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
             $twitter->send('[WA] Item Bought: ' . $user . ' bought ' . $buyQuantity . ' x ' . $auction->fullname . ' for ' . $currencyPrefix . $itemPrice . $currencyPostfix . ' each from ' . $itemOwner . '. At ' . date("H:i:s") . '. ' . $shortLinkToAuction . ' #webauction');
         } catch (Exception $e) {
             //may have reached twitter daily limit
         }
     }
     $player->buyItem($buyQuantity);
     $owner->sellItem($buyQuantity);
     $_SESSION['success'] = str_replace(array('#buyQuantity#', '#auctionFullname#', '#auctionOwner#', '#totalPrice#'), array($buyQuantity, $auction->fullname, $auction->owner, $currencyPrefix . $totalPrice . $currencyPostfix), $lang['purchaseItem']['buy_success']);
     if ($toDelete) {
         $auction->delete();
     }
     header("Location: ../index.php");
 } else {
     $_SESSION['error'] = $lang['purchaseItem']['buy_own_item'];
     header("Location: ../index.php");
 }
Beispiel #15
0
 public function send($message)
 {
     return parent::send($message);
     //echo shell_exec('/home/stockchase/EditorFunctions/python/mytweet.py "' . $message .'"');
     flush();
 }