/** * Adds a post to Twitter * * @param string $question Question * @param string $tags String of tags * @param string $link URL to FAQ * * @return void */ public function addPost($question, $tags, $link) { $hashtags = ''; if ($tags != '') { $hashtags = '#' . str_replace(',', ' #', $tags); } $message = PMF_String::htmlspecialchars($question); $message .= ' ' . $hashtags; $message .= ' ' . $link; $this->connection->post('statuses/update', array('status' => $message)); }
public function push($Account, $TwitterStatus) { $NGPushIni = eZINI::instance('ngpush.ini'); $Token = self::getToken($Account); if (!$Token) { self::requestToken($Account); $Token = self::getToken($Account); } if ($Token) { $tokenCredentials = explode('%%%', $Token); $connection = new TwitterOAuth($NGPushIni->variable($Account, 'ConsumerKey'), $NGPushIni->variable($Account, 'ConsumerSecret'), $tokenCredentials[0], $tokenCredentials[1]); $connection->host = "https://api.twitter.com/1.1/"; $TwitterResponse = $connection->post('statuses/update', array('status' => $TwitterStatus)); self::$response['response'] = $TwitterResponse; //Let's analyize some Twitter JSON response (lots of data but no clear structure and no status) if ($TwitterResponse->error) { self::$response['status'] = 'error'; self::$response['messages'][] = $TwitterResponse->error; } elseif ($TwitterResponse->errors) { self::$response['status'] = 'error'; foreach ($TwitterResponse->errors as $TwitterResponseError) { self::$response['messages'][] = $TwitterResponseError->message; } } else { self::$response['status'] = 'success'; if ($TwitterResponse->created_at) { self::$response['messages'][] = 'Status is published!'; } } } else { self::$response['status'] = 'error'; self::$response['messages'][] = 'You need access token to use this application with Twitter.'; } return self::$response; }
function post($message) { error_reporting(0); $acces = array('consumer_key' => $this->auth['consumer_key'], 'consumer_secret' => $this->auth['consumer_secret'], 'access_token' => $this->auth['access_token'], 'access_secret' => $this->auth['access_secret']); $twitter = new TwitterOAuth($acces['consumer_key'], $acces['consumer_secret'], $acces['access_token'], $acces['access_secret']); $response = $twitter->post('statuses/update', array('status' => $message)); }
public static function postMessage($params, $data) { $attachment = array('message' => $data['message']); $message = array(); if (!class_exists('TwitterOAuth')) { require_once dirname(__FILE__) . '/elements/twitter/twitteroauth.php'; } $user = $params->params->get('groupid'); $checked = 0; $log = ''; $publish = 1; if (isset($user->checked)) { $checked = 1; $twitter = unserialize($params->params->get('access_token')); $connection = new TwitterOAuth($params->params->get('app_appid'), $params->params->get('app_secret'), $twitter['oauth_token'], $twitter['oauth_token_secret']); $parameters = array('status' => $attachment['message']); $status = $connection->post('statuses/update', $parameters); if (isset($status->errors)) { $log = Jtext::_('PUBLISHED_TWITTER_PROFILE_SENDMESSAGE') . ' <a href="https://twitter.com/' . $user->screen_name . '" target="_blank" style="text-decoration: underline;">' . $user->name . '</a> - ' . $status->errors[0]->message . ' <br/>'; $publish = 0; } else { $log = Jtext::_('PUBLISHED_TWITTER_PROFILE_SENDMESSAGE') . ' <a href="https://twitter.com/' . $user->screen_name . '" target="_blank" style="text-decoration: underline;">' . $user->name . '</a> - ' . JTEXT::_('PUBLISHED_TWITTER_PROFILE_SENDMESSAGE_SUCCESSFULL') . '<br/>'; $publish = 1; } } $message['log'] = $log; $message['publish'] = $publish; $message['checked'] = $checked; $message['type'] = 'twitter'; return $message; }
/** * @Route("/souphpsp/x") */ public function xAction() { $oauth = new \TwitterOAuth('qPLsh4YhO2Ui8KmM6vRtw', 'CbtjJPSD1yxxJfbbr4TPKX7K0UCExnffk5Qg', '18179550-Z6V17Ly1tvyOEiqCjuq1NfenI71FacvFrlqYT8Bqb', 'CkS51WZMERauimVxZBOxVQVLtBeDzIZCFLzCQpGzlg'); $res = $oauth->post('http://api.twitter.com/1/direct_messages/new.json', array('screen_name' => 'rdohms', 'text' => 'mytext')); var_dump($res); return new \Symfony\Component\HttpFoundation\Response(); }
public static function post($user, $text) { $culture = $user->getCulture(); $profile = $user->getGuardUser()->getProfile(); $connection = new TwitterOAuth(sfConfig::get("app_twitter_api_consumer_key_{$culture}"), sfConfig::get("app_twitter_api_consumer_secret_{$culture}"), $profile->getTwOauthToken(), $profile->getTwOauthTokenSecret()); $connection->post('statuses/update', array('status' => $text)); }
function post_on_behalf_of($user, $message) { if (!empty($user['tw_oauth_token']) && !empty($user['tw_oauth_token_secret'])) { $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $user['tw_oauth_token'], $user['tw_oauth_token_secret']); $resp = $connection->post('statuses/update', array('status' => $message)); return (200 == $connection->http_code); } }
public function message($userID, $text) { /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth($this->appCode, $this->appSecret, $this->token['oauth_token'], $this->token['oauth_token_secret']); /* Get logged in user to help with tests. */ $request = (array) $connection->post('direct_messages/new', array('user_id' => $userID, 'text' => $text)); return true; }
public static function statusesUpdate($oauthToken, $oauthTokenSecret, $status, array $extraData = array()) { list($consumerKey, $consumerSecret) = bdSocialShare_Option::getTwitterConsumerPair(); $twitter = new TwitterOAuth($consumerKey, $consumerSecret, $oauthToken, $oauthTokenSecret); $response = $twitter->post('statuses/update', array_merge(array('status' => $status), $extraData)); $responseArray = (array) $response; return $responseArray; }
public function postDirectContentOnTwitter($content, $user_token, $user_secret) { $status_update = $content; include_once '../Vendor/twitter/twitter/lib/twitteroauth.php'; include_once '../Vendor/twitter/twitter/lib/secret.php'; $connectionNew = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $user_token, $user_secret); $connectionNew->post('statuses/update', array('status' => $status_update)); }
public function postContentOnTwitter($content, $id, $user_token, $user_secret){ $link = SITE_PATH.'business_feeds/view_feed_content/'.$this->Fp->encrypt($id); $status_update = $content['message'].' '.$link; include_once('../Vendor/twitter/twitter/lib/twitteroauth.php'); include_once('../Vendor/twitter/twitter/lib/secret.php'); $connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $user_token, $user_secret); $connection->post('statuses/update', array('status'=>$status_update)); }
function post($message = "hello") { // $message $connection = new TwitterOAuth(WRA_CONF::$twiappid, WRA_CONF::$twiappsecret, $this->oauth_token, $this->oauth_token_secret); // $content = $connection->get('account/rate_limit_status'); $res = $connection->post('statuses/update', array('status' => $message)); // WRA::debug($res); // $content = $connection->get('users/show',array('user_id'=> $_SESSION['access_token']['user_id'])); }
public function data() { $this->_mandatory(array('message')); $message = $this->input->post('message'); $config = new Controllers_Api_Twitter_Config_App(); $connection = new TwitterOAuth($config->config['consumer_key'], $config->config['consumer_secret'], $_REQUEST['token_twitter'], $_REQUEST['token_secret_twitter']); //Post text to twitter $my_update = $connection->post('statuses/update', array('status' => $message)); echo json_encode($my_update); }
public function _tweet_report() { $report = Event::$data; $tweet = $report->incident_title . ' @ ' . $report->location->location_name . ' http://boskoi.org/' . $report->id; //fb($tweet,'Tweet text'); $tw = new TwitterOAuth(Kohana::config('tweetkoi.consumer_key'), Kohana::config('tweetkoi.consumer_secret'), Kohana::config('tweetkoi.oauth_token'), Kohana::config('tweetkoi.oauth_token_secret')); $result = $tw->post('statuses/update', array('status' => $tweet)); print_r($result); return true; }
/** * Sends a tweet * * @param string $txt the tweet text to send * @param bool $limit DEPRECATED * * @return string URL of tweet (or false on failure) */ public function sendTweet($txt, $limit = false) { if (!$this->authenticatedAsUser) { return false; } $resp = $this->api->post('statuses/update', array('status' => $txt)); if (200 != $this->api->lastStatusCode()) { return false; } return $resp; }
function sendTweet($msg) { $consumerKey = 'QgE2NWrvsrTrGjg0bVCo6VIwU'; $consumerSecret = 'MpNr7EdGlJQClAMuCsmrGqSblEzoCXDbagYlwVvJs6eVFggrp0'; $oAuthToken = '2912192883-nI7A2LMfh8z2M7IwvwSAfpZAHeG5eLOsdu2ZDNn'; $oAuthSecret = 'sDFejAvhmRYYJGbR1JMwLCfZmRlfy7wc1SC9GuzS4hZZ0'; if (isset($msg)) { $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret); $tweet->post('statuses/update', array('status' => $msg)); } return true; }
public function post_to($tweet) { $current_user = $tweet->user; if ($current_user && ($current_user->type == Users_Model::USER_TYPE_HAS_TWITTER || $current_user->type == Users_Model::USER_TYPE_TWITTER)) { $verifier = array('oauth_token' => $current_user->twitter_oauth_token, 'oauth_token_secret' => $current_user->twitter_oauth_token_secret); $twitter_config = get_config('twitter'); $connection = new TwitterOAuth($twitter_config['key'], $twitter_config['secret'], $verifier['oauth_token'], $verifier['oauth_token_secret']); $status = $connection->post('statuses/update', array('status' => $tweet->text)); return $status; } return false; }
public static function postToTwitter($message) { $message = self::shortMessage($message); $connection = new TwitterOAuth(self::TWITTER_CONSUMER_KEY, self::TWITTER_CONSUMER_SECRET, self::TWITTER_TOKEN, self::TWITTER_TOKEN_SECRET); $twitterInfos = $connection->get('account/verify_credentials'); if (200 == $connection->http_code) { $parameters = array('status' => $message); $status = $connection->post('statuses/update', $parameters); return $status; } return ""; }
function postTweet($name, $tweet) { $status_msg = $tweet . " from " . $name; require_once 'twitteroauth/twitteroauth.php'; require_once 'twitteroauth/config_smsMouth.php'; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET); $tweetPost = $connection->post('statuses/update', array('status' => $status_msg)); if (!empty($tweetPost->created_at)) { $this->return["result"] = "Your tweet :{$tweetPost->text} has been posted"; } else { $this->return["result"] = "Some error occured"; } }
function send_tweet($message) { // Insert your keys/tokens $consumerKey = 'FRqfYko2uRteru1obCQ'; $consumerSecret = 'Sjt98BSRPIUg8tOPwS1iLNPMOxIiAsxFD2jcCNTY'; $OAuthToken = '495718220-pSpX3TdZXg0lU3N9te3OX7egvszRLc3LdSpx3rfU'; $OAuthSecret = 'N5OjADaC2iYVGXxIOWidUEYgnzEbFEl9HVQU3fVFOzI'; // create new instance $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret); // Send tweet $tweet->post('statuses/update', array('status' => "{$message}")); echo $tweet->http_code . "\n"; }
public function update($message) { /** @var ArticlesContainer $container */ $container = $this->modx->getObject('ArticlesContainer', $this->article->get('parent')); if (!$container) { return false; } $keys = $container->getTwitterKeys(); $accessToken = $container->decrypt($this->config['notifyTwitterAccessToken']); $accessTokenSecret = $container->decrypt($this->config['notifyTwitterAccessTokenSecret']); $connection = new TwitterOAuth($keys['consumer_key'], $keys['consumer_key_secret'], $accessToken, $accessTokenSecret); $output = $connection->post('statuses/update', array('status' => $message)); return $output; }
function authorize_twitter($postId) { $connection = self::get_twitter_oauth(true); $token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']); if (!empty($token_credentials['oauth_token']) && !empty($token_credentials['oauth_token_secret'])) { $key_secret = self::get_twitter_key_secret(); extract($key_secret); $connection_for_post = new TwitterOAuth($key, $secret, $token_credentials['oauth_token'], $token_credentials['oauth_token_secret']); $status = premise_get_social_share_twitter_text($postId, true); $connection_for_post->post('statuses/update', array('status' => $status)); self::set_cookie($postId); } self::redirect(get_permalink($postId)); }
/** * Sends $tweet through the twitter account provided by $twitter * You have to register an application on http://dev.twitter.com/apps to get comsumer and access keys. * @params: * $twitter :array * $twitter['consumer_key'] :string * $twitter['consumer_secret'] :string * $twitter['access_key'] :string * $twitter['access_secret'] :string * $tweet :string, the message to be posted *@returns true in success, false otherwise */ function twitter($twitter, $tweet) { $connection = new TwitterOAuth($twitter['consumer_key'], $twitter['consumer_secret'], $twitter['access_key'], $twitter['access_secret']); $connection->decode_json = false; $response = $connection->post('statuses/update', array('status' => $tweet)); $http_info = $connection->http_info; if ($http_info['http_code'] != 200) { log_this("error: tried to twitter \"{$tweet}\" on @" . $twitter['name'], $response); return false; } else { log_this("success: twittered \"{$tweet}\" on @" . $twitter['name'], $response); return true; } }
function tweetPercentage($current) { global $socialUrl; // tweet the max percentage for last night $percent = $current['percent']; $time = $current['timestamp']; $message = "While you were sleeping, #windenergy reached {$percent}% of the National Grid's electricity demand. {$socialUrl}"; $connection = new TwitterOAuth(API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); $status = $connection->post('statuses/update', array('status' => $message)); if (1) { echo $message; } else { echo "failed to tweet"; } }
function tweetPercentage($current) { global $socialUrl; // tweet the percentage milestone :) $percent = $current['percent']; $time = $current['timestamp']; $message = "Right now #wind is meeting {$percent}% of the National Grid's electricity demand. {$socialUrl}"; $connection = new TwitterOAuth(API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); $status = $connection->post('statuses/update', array('status' => $message)); if (1) { query("INSERT INTO tweets (percentage, timestamp) VALUES ({$percent}, '{$time}')"); echo "tweeted!"; } else { echo "failed to tweet"; } }
function updateTwitter($status) { $oauth_token = gettwitterEmail(); $oauth_token_secret = gettwitterPass(); $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret); $connection->format = 'xml'; $connection->decode_json = FALSE; $connection->post('statuses/update', array('status' => "{$status}")); // check that everything went OK. // twitter returns a long string that contains the update when things // are ok. $result = $connection->response; if (eregi("Could not authenticate you", $result)) { echo " <img src=\"action_stop.gif\" border=\"0\" /> twitter error: " . $result . "<br />"; } else { echo " <img src=\"icon_accept.gif\" border=\"0\" /> twitter updated. "; } }
/** * Title * * Description * * @access public */ function postToTwitter($message) { if (!defined('SETTINGS_TWITTER_CKEY')) { return 0; } $consumerKey = SETTINGS_TWITTER_CKEY; $consumerSecret = SETTINGS_TWITTER_CSECRET; $oAuthToken = SETTINGS_TWITTER_ATOKEN; $oAuthSecret = SETTINGS_TWITTER_ASECRET; if ($consumerKey == '' || $consumerSecret == '' || $oAuthSecret == '' || $oAuthToken == '') { return 0; } require_once ROOT . 'lib/twitter/twitteroauth.php'; // create a new instance $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret); //send a tweet $tweet->post('statuses/update', array('status' => $message)); }
public function main() { // Connect to twitter $connection = new TwitterOAuth($this->consumerKey, $this->consumerKeySecret, $this->oauthToken, $this->oauthTokenSecret); // Pass the status message as a parameter $parameters = array('status' => $this->message); // Post the data to the API endpoint $status = $connection->post('statuses/update', $parameters); if (isset($status->error)) { // Error: fail the build throw new BuildException($status->error); } else { $this->log('Status posted to twitter'); } // Sleep 10 seconds to prevent tweet being filtered by Twitter, which happens // when this TwitterUpdateTask is executed multiple times after each other sleep(10); }
function tweet_post() { // set global post var global $post; // keys/tokens $consumerKey = '731fOaF7mZFFmCOvuhherA'; $consumerSecret = 'HTeEP7tS9PrTHZsgNXMkX7YhrfGHOrCBCQq0QITzR0'; $oAuthToken = '1199466020-pokzhoWEqS1yti5jh4bDsg2EVfeVFr7DK8Cv8NW'; $oAuthSecret = 'yz5LfTRXLCxn6FVOdOQt5lk0zXyMZftylaVvxb3YFI'; // path to twitteroauth.php require_once 'twitteroauth.php'; // create new instance $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret); // the message $message = get_the_title($post->ID) . ' ' . home_url('/' . $post->ID); // let's send the tweet! $tweet->post('statuses/update', array('status' => "{$message}")); }
public function __construct() { $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET); //OBTAIN THE STARRED PROJECTS $curl = new Curl(); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $curl->get(URL_GITHUB); if ($curl->error) { echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage; } else { $existe = false; do { //PROCESS A BEAUTY STRING $random = array_rand($curl->response); $name = $curl->response[$random]->name; $description = $curl->response[$random]->description; $cutdescription = strlen($description) > 70 ? substr($description, 0, 60) . '...' : $description; $home_url = $curl->response[$random]->html_url; //PUBLISH YET? if ($this->connectDB()) { $query = $this->conn->prepare('SELECT id_twitter FROM bot_github WHERE nombre LIKE :nombre;'); $query->bindParam(':nombre', $name, PDO::PARAM_STR); $query->execute(); $result_row = $query->fetchObject(); if (isset($result_row->id_twitter)) { $existe = true; } } } while ($existe); $tweet = $name . ': ' . $cutdescription . ' ' . $home_url; //TWEET $return = $twitter->post('statuses/update', array('status' => $tweet)); if ($this->connectDB()) { //SAVE THE TWEET $query = $this->conn->prepare('INSERT INTO bot_github (nombre, id_twitter) VALUES (:nombre, :id_twitter)'); $query->bindParam(':nombre', $name, PDO::PARAM_STR); $query->bindParam(':id_twitter', $return->id, PDO::PARAM_STR); $query->execute(); } echo '<pre>'; print_r($return); echo '</pre>'; } }