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"; } }
/** * @param Article $article * @param string $header */ public function provide(Article $article, $header = "") { $this->twitter->post("statuses/update", array("status" => "{$header} {$article->getTitle()} >> http://matomepp.net/p/{$article->getArticleId()}")); if ($this->twitter->getLastHttpCode() != 200) { throw new \RuntimeException(json_encode($this->twitter->getLastBody())); } $this->storeTweets($article); }
public function postStatus($status) { try { $connection = new TwitterOAuth($this->_consumerKey, $this->_consumerSecret, $this->_oauthToken, $this->_oauthSecret); $content = $connection->get('account/verify_credentials'); $connection->post('statuses/update', array('status' => $status)); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } }
function TwitterLink() { if ($_POST['checkTwitterLink'] != null) { require dirname(__FILE__) . '/twitteroauth/autoload.php'; // OAuthオブジェクト生成 $param = twitterparam(); $connection = new TwitterOAuth($param[consumer_key], $param[consumer_secret], $param[access_token], $param[access_token_secret]); $postMessage = $param[title] . $_POST['post_title'] . " "; $url = $postMessage . get_permalink(); //ツイート $res = $connection->post("statuses/update", array("status" => $url)); } }
/** * @return array|object|string */ public function delete() { if ($this->id) { try { $post = $this->twitter->post('statuses/destroy/' . $this->id); return $post; } catch (Exception $e) { return $e->getMessage(); } } else { return "Post id not set"; } }
public function loginTwitter($data) { if (!Session::has('access_token')) { $connection = new TwitterOAuth(config('socialpack.composer_key'), config('socialpack.composer_secret')); $callback_url = url('/') . '/callbackTwitter'; $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => (string) $callback_url)); Session::put('oauth_token', $request_token['oauth_token']); Session::put('oauth_token_secret', $request_token['oauth_token_secret']); $url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token'])); return redirect()->away($url); } else { $access_token = Session::get('access_token'); $connection = new TwitterOAuth(config('socialpack.composer_key'), config('socialpack.composer_secret'), $access_token['oauth_token'], $access_token['oauth_token_secret']); if (isset($data) && !empty($data)) { if (isset($data['profile']) && !empty($data['profile'])) { if ($data['profile'] == "yes") { // getting basic user info $user = $connection->get("account/verify_credentials"); return $user; } } if (isset($data['post_tweet']) && !empty($data['post_tweet'])) { if ($data['post_tweet']["show"] == "yes") { // posting tweet on user profile $post = $connection->post('statuses/update', array('status' => $data['post_tweet']["message"])); return $post; } } if (isset($data['recent_tweets']) && !empty($data['recent_tweets'])) { if ($data['recent_tweets']["show"] == "yes") { // getting recent tweeets by user 'snowden' on twitter $tweets = $connection->get('statuses/user_timeline', ['count' => 200, 'exclude_replies' => true, 'screen_name' => 'snowden', 'include_rts' => false]); $totalTweets[] = $tweets; $page = 0; for ($count = 200; $count < 500; $count += 200) { $max = count($totalTweets[$page]) - 1; $tweets = $connection->get('statuses/user_timeline', ['count' => 200, 'exclude_replies' => true, 'max_id' => $totalTweets[$page][$max]->id_str, 'screen_name' => 'snowden', 'include_rts' => false]); $totalTweets[] = $tweets; $page += 1; } return $totalTweets; } } } } }
function index() { //$this->get_localhost(); $tokens = array("consumer_key" => "nI5mbQJ90srwBDIPGBrAIUphJ", "consumer_key_secret" => "EMubqMnZNuIIy6echinNa7uXd3xM67jfyZ6SmPiiXkUUdcCApb", "access_token" => "38682087-3RjO1RdEQpAmnt5rzwhiFiWKsCACQKY1zHfPYpAkF", "access_token_secret" => "gl4WAIpTRSFnld6kJxaD68pcn9IyEEJzGQO4z7r3TR1zm"); $connection = new TwitterOAuth($tokens["consumer_key"], $tokens["consumer_key_secret"], $tokens["access_token"], $tokens["access_token_secret"]); $data = $connection->post("oauth2/token"); $timeline = $connection->get("statuses/user_timeline", array("screen_name" => "aldouswright")); echo "<pre>"; echo "<ul>"; foreach ($timeline as $tweet) { echo "<li>" . $tweet->text . "</li>"; } echo "</ul>"; print_r($timeline); echo "</pre>"; die; }
/** * ツイートを投稿する関数 * * @param object $connection 投稿に使用する TwitterOAuth のインスタンス * @param array $param Twitter に送信するパラメータ * @param int $retryLimit 最大再試行回数 * @return bool 投稿に成功すれば true、失敗すれば false */ public static function postTweet(TwitterOAuth $connection, array $param, $retryLimit = 3) { Log::info("Twitter に tweet を POST します:"); Log::info($param); for ($retry = 0; $retry < $retryLimit; ++$retry) { if ($retry > 0) { sleep(1); } $result = $connection->post('statuses/update', $param); if (is_object($result) && isset($result->id_str) && isset($result->text)) { Log::success("Tweet を投稿しました"); Log::success(['id' => $result->id_str, 'text' => $result->text]); return true; } Log::warning("Tweet の投稿に失敗しました"); } Log::error("Tweet を投稿できませんでした"); Log::error($param); return false; }
/** * @return void * @throws \BuildException */ public function main() { $twitterConsumerKey = $this->getProjectProperty('twitter.consumer.key'); $twitterConsumerSecret = $this->getProjectProperty('twitter.consumer.secret'); $twitterAccessToken = $this->getProjectProperty('twitter.access.token'); $twitterAccessTokenSecret = $this->getProjectProperty('twitter.access.token.secret'); $projectVersion = $this->getProjectProperty('project.version'); $projectVendor = $this->getProjectProperty('project.vendor'); $projectName = $this->getProjectProperty('project.name'); $tweet = "{$projectVendor}/{$projectName} {$projectVersion}"; if (!empty($this->projectUrl)) { $tweet .= ' | ' . $this->projectUrl; } if (!empty($this->projectTags)) { $tweet .= ' | #' . implode(", #", array_filter(array_map("trim", explode(",", $this->projectTags)))); } $this->log('this tweet will be sent'); $this->log($tweet); try { $request = new \InputRequest('do you wanna send this tweet? [y/n]:'); $this->project->getInputHandler()->handleInput($request); $answer = trim($request->getInput()); } catch (\IOException $e) { throw new \BuildException("prompt failed. reason: " . $e->getMessage()); } $answer = empty($answer) ? 'n' : substr(strtolower($answer), 0, 1); if ($answer == 'n') { $this->log('skipped tweeting to twitter'); return; } $this->log('tweet sending ...'); try { $connection = new TwitterOAuth($twitterConsumerKey, $twitterConsumerSecret, $twitterAccessToken, $twitterAccessTokenSecret); $connection->post("statuses/update", array("status" => $tweet)); } catch (\Exception $e) { throw new \BuildException("sending failed. reason: " . $e->getMessage()); } $this->log('tweet was send'); }
// Get the keys from Keys and Access tokens $oauth = new TwitterOAuth('Consumer Key', 'Consumer Secret', 'Access Token', 'Access Token Secret'); // You can fill in more names if you want. they're tweeted at randomly $screen_names[] = 'natefanaro'; $tweets = array(); $i = 0; foreach ($lines as $line) { $length = strlen($line); // making sure it will fit if (isset($tweets[$i]) && strlen($tweets[$i] . $line) > 140) { $i++; } // filling in tweets for users if (!isset($tweets[$i])) { $screen_name = $screen_names[rand(0, count($screen_names) - 1)]; $tweets[$i] = '@' . $screen_name . ' ' . $line . "\n"; } else { $tweets[$i] .= $line . "\n"; } } while (count(array_keys($tweets))) { $tweet = array_pop($tweets); // uppercase if you want to be extra annoying //$tweet = strtoupper($tweet); print $tweet; $new_id = $oauth->post('statuses/update', array('status' => $tweet)); if ($oauth->getLastHttpCode() != 200) { print_r($new_id); } sleep(30); }
function postToTwitter($message, $mediaURL = null) { $tag = str_replace(' ', '', SYSTEM_SITE_NAME . SYSTEM_YEAR); $message = $message . ' #' . $tag; if (strlen($message) > 140) { return false; } $connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET); $params = ['status' => $message]; if ($mediaURL) { $mediaURL = unshorten_url($mediaURL); $media = $connection->upload('media/upload', ['media' => $mediaURL]); if ($media) { $params['media_ids'] = $media->media_id_string; } } return $connection->post("statuses/update", $params); }
<div class="col-md-12"> <?php require "inc/twitter_credentials.php"; require "inc/Database.php"; require "vendor/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; $pdo = Database::connect(); $getTweets = $pdo->prepare("SELECT *, RAND() as rand FROM tweets ORDER BY rand LIMIT 1"); $getTweets->execute(); if ($getTweets->rowCount() > 0) { while ($row = $getTweets->fetch()) { $tweet = $row['tweet']; } $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); $content = $connection->get('account/verify_credentials'); $connection->post('statuses/update', array('status' => $tweet)); if ($connection->getLastHttpCode() === 200) { echo '<p><strong>Your latest tweet:</strong> ' . $tweet . '</p>' . PHP_EOL; } else { echo '<p><strong>Error:</strong> A problem ocurred. You filled your Twitter credentials correctly? Or walk abusing the Twitter API?</p>' . PHP_EOL; } } else { echo '<p><strong>Error:</strong> You have no tweets registered in the database or not filled data connection properly.</p>' . PHP_EOL; } Database::disconnect(); ?> </div> </div> <hr>
require 'twitteroauth/autoload.php'; require 'common.php'; use Abraham\TwitterOAuth\TwitterOAuth; $tw = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['access_token'], $_SESSION['access_token_secret']); echo '<div class="TweetArea">'; if (isset($_POST['reply'])) { $reply = '@' . $_POST['reply'] . ' '; $tweet_id = $_POST['tweet_id']; } else { $reply = ''; $tweet_id = null; } echo '<p class="Tweetstring">Tweet : Reply</p>'; echo '<form action="" method="post">'; //echo '<input class="Tweet-input-text" type="text" value="'.$text.'" name="tweet">'; echo '<textarea class="Tweet-input-text" cols="30" roms="5" wrap="soft" name="tweet"></textarea>'; echo '<input class="Tweet-submit-text" type="submit" name="" value="送信">'; echo '<input type="hidden" value="' . $tweet_id . '" name="tweet_id">'; echo '<input type="hidden" value="' . $reply . '" name="reply">'; echo '</form>'; echo '<p class="Backbutton"><a href="update.php">×</a></p>'; echo '</div>'; if (isset($_POST['tweet'])) { $params = array('status' => $_POST['reply'] . $_POST['tweet'], 'in_reply_to_status_id' => $_POST['tweet_id']); $tw->post("statuses/update", $params); unset($_POST['tweet']); header("Location: show.php"); } ?> </body> </html>
require_once "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; $apikey = "IaeaRWz1u6JccWAgYalbFI29H"; $apisecret = "HSpeshWGShdzVlKrnjJIg17wUuh5dCMOo8Lbu10BND44BaQgrm"; $accesstoken = "41576807-xPjv9hY6w8iSDwF9hrq1fwCh3KQi3m2ktofOAdzIm"; $accesssecret = "VcrcTlhKnj665CxGt7NtN4iu3vLP453TS1IdsqisD9wFU"; $connection = new TwitterOAuth($apikey, $apisecret, $accesstoken, $accesssecret); /* $content = $connection->get("account/verify_credentials"); print_r($content); */ /* $tweets = $connection->get("statuses/user_timeline", array("count" => 10, "screen_name" => "twitterapi")); print_r($tweets); */ /* foreach($tweets as $tweet) { echo $tweet->text; echo "<br />"; echo "Favorites: ".$tweet->favorite_count; echo "<br /><br />"; } */ /* $mentions = $connection->get("statuses/mentions_timeline", array("count" => 5)); print_r($mentions); */ $statuses = $connection->post("statuses/update", array("status" => "This is an application test post.")); print_r($statuses);
$connection->post('statuses/destroy/' . $_GET["post"], array()); header('Location: app.php'); } //Gets Timeline function getConnectionWithAccessToken($oauth_token, $oauth_token_secret) { require "autentificacion.php"; $connection = new TwitterOAuth($consumer_key, $consumer_secret, $token, $token_secret); return $connection; } $connection = getConnectionWithAccessToken($token, $token_secret); $content = $connection->get("statuses/user_timeline"); //Post tweet $tweet = @$_POST['tweet']; if ($tweet != "") { $statues = $conexion->post("statuses/update", array("status" => $tweet)); header('Location: app.php'); } if (isset($_GET['logout'])) { session_unset(); $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); } ?> <!DOCTYPE html> <html lang="en"><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Real Trends test</title>
<?php require_once __DIR__ . '/config.php'; // package // - Composer use Abraham\TwitterOAuth\TwitterOAuth; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); // $content = $connection->get("account/verify_credentials"); // $content = $connection->get("statuses/home_timeline", ['count'=>3]); // var_dump($content); $res = $connection->post("statuses/update", ['status' => 'ドットインストールがおすすめ! http://dotinstall.com #dotinstall']); if ($connection->getLastHttpCode() === 200) { echo 'Success!' . PHP_EOL; } else { echo 'Error!' . $res->errors[0]->message . PHP_EOL; }
<?php //Bibliotecas necesarias. require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; //Key de la aplicacion de twitter. $consumerKey = 'uNF8aNETIfskqNsMMkybIA'; $consumerSecret = 'bB33A8QBz97AdEw9UpcSHxwrv586Pf2Mujy4tYBdi8M'; $access_token = '216136539-EGLcwsMTS8DH12WaPYSKZuid4wWbh1jxcuxL90eo'; $access_token_secret = 'ijWStO34zLQtU1kKGYXt6aybM3hK5FqKxTiJYwHORR1lg'; //Conexiones a twitter. $connection = new TwitterOAuth($consumerKey, $consumerSecret, $access_token, $access_token_secret); $content = $connection->get("account/verify_credentials"); //Obtenemos todas las imagenes del subreddit. $json = file_get_contents('https://www.reddit.com/r/pics.json'); $obj = json_decode($json); //Generamos un numero aleatorio. $randomInt = rand(1, 25); //Obtenemos la url de la imagen aleatoria. $img = $obj->data->children[$randomInt]->data->preview->images[0]->source->url; //Agregamos la imagen. $media1 = $connection->upload('media/upload', ['media' => $img]); $parameters = ['status' => 'Probando...', 'media_ids' => implode(',', [$media1->media_id_string])]; //Postemos el tweet y obtenemos su resultado. $result = $connection->post('statuses/update', $parameters);
//Parse the recent tweets and pull out the names of recently tweeted about CPs to avoid needing any storage / DB. $recentlyTweetedFull = []; $recentTweets = $connection->get('statuses/user_timeline'); foreach ($recentTweets as $recentTweet) { if (strtotime($recentTweet->created_at) > time() - 60 * 60 && strpos($recentTweet->text, "is FULL") !== false) { $recentlyTweetedFull[] = trim(str_replace('&', '&', substr($recentTweet->text, 0, strpos($recentTweet->text, " is FULL")))); } } foreach ($fullCarParks as $carpark) { //Check if this car park was mentioned recently. if (in_array($carpark['name'], $recentlyTweetedFull)) { echo $carpark['name'] . " is full, but we tweeted about it less than an hour ago.\n"; continue; } //Create the tweet text & post it. $status = $carpark['name'] . " is FULL"; if (count($emptyCarParks) > 0) { $status .= ", but " . count($emptyCarParks) . " car parks still have plenty of space: http://www.bathcarparks.co.uk/"; } else { $status .= "."; } $tweetDetails = array("status" => $status, "lat" => 51.381521, "long" => -2.360389, "place_id" => "1db4f0a70fc5c9db"); echo "Tweeting: " . $tweetDetails['status'] . "\n"; $response = $connection->post("statuses/update", $tweetDetails); var_dump($response); sleep(1); } } else { echo "No car parks are full. Not tweeting. \n"; } die("Done in " . (microtime(true) - $startTime) . " seconds. \n");
?> </ul> <!-- Header --> <div class="container"> <br /> <br /> <img src="AskTwitter.png" style="width:180px"> <h5>What's something that Google can't answer?</h5> </div> <?php // Handle a user posting a question. if (isset($_GET['submitquestion'])) { // Post the tweet and redirect indicating success. $statues = $connection->post("statuses/update", array("status" => $_GET['tweet'])); header("Location: " . $base_url . "?success"); exit; } // Display success message if a question/answer is posted. if (isset($_GET['success'])) { ?> <div class="container"> <div class="alert alert-success" role="alert"> Your submission was successful! </div> </div> <?php } if (!isset($_GET['qid']) && $logged_in) { ?>
/** * Posts the message to twitter * @param string $message The message to post to twitter */ function postTwitter($message) { global $twitterConfig; $connection = new TwitterOAuth($twitterConfig['consumerKey'], $twitterConfig['consumerSecret'], $twitterConfig['accessToken'], $twitterConfig['accessTokenSecret']); $statues = $connection->post("statuses/update", ["status" => $message]); print_r($statues); }
/** * Make POST requests to the API. * * @param string $path * @param array $parameters * * @return array|object */ public function post($path, array $parameters = array()) { return $this->twitterOAuth->post($path, $parameters); }
<html> <head> <title>Tweet</title> </head> <body> <pre> <?php session_start(); require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; require "initialize.php"; #APIにアクセスするためのアクセストークンを用いて$connectionを作成 $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']); #"Hello,world!"とツイートする、$resultにはbool型で実行結果が出力される $result = $connection->post('statuses/update', array('status' => "Hello,world!")); if ($result) { print "success!"; } else { print "failed..."; } #ログインしたアカウントのプロフィールの取得、出力 var_dump($connection->get("account/verify_credentials")); ?> </pre> </body> </html>
<?php $root = __DIR__; $loader = (require $root . '/vendor/autoload.php'); $loader->add('', $root . '/classes/'); $pixie = new \App\Pixie(); $pixie->bootstrap($root); use Abraham\TwitterOAuth\TwitterOAuth; $api = new TwitterOAuth($pixie->config->get('twitter.consumer_key'), $pixie->config->get('twitter.consumer_secret'), $argv[1], $argv[2]); $devs = $pixie->config->get('devs'); file_put_contents($root . '/log.txt', "started\n", FILE_APPEND); foreach ($devs as $dev) { $res = $api->post('friendships/create', array('screen_name' => $dev['twitter'])); } file_put_contents($root . '/log.txt', "finished\n", FILE_APPEND);
require_once __DIR__ . '/controller/config.php'; require_once __DIR__ . '/controller/Twitterlogin.php'; $twitterLogin = new MyApp\TwitterLogin(); use Abraham\TwitterOAuth\TwitterOAuth; if ($twitterLogin->isLoggedIn()) { $me = $_SESSION['me']; MyApp\Token::create(); } else { header('Location: http://' . $_SERVER['HTTP_HOST'] . '/devAid-v1.2/index.php'); exit; } $screen_name = $me->tw_screen_name; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $me->tw_access_token, $me->tw_access_token_secret); // ユーザIDでフォローする $connection->post('friendships/create', ['screen_name' => 'hatebu']); // ユーザ名でユーザ情報を取得 $user_info = $connection->get('users/show', ['screen_name' => $screen_name]); $user_name = $user_info->name; $user_id = $user_info->screen_name; $user_img = $user_info->profile_image_url_https; $user_follows = $user_info->friends_count; $user_followers = $user_info->followers_count; ?> <!DOCTYPE html> <html lang="en"> <head> <title>両思いったー</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
/** * @depends testPostStatusesUpdateUtf8 */ public function testPostStatusesDestroy($status) { $this->twitter->post('statuses/destroy/' . $status->id_str); $this->assertEquals(200, $this->twitter->getLastHttpCode()); }
echo $crawling_friends_url; echo '</p>'; } */ ?> </div> </div> <div class="sidebar right"> <ul> <?php //外部ファイルにしていきたい //リツイートされたか if (isset($_POST['retweet'])) { $tw->post('statuses/retweet/' . $_POST['retweet']); unset($_POST['retweet']); } if (isset($_POST['favo'])) { $tw->post('favorites/create', ['id' => $_POST['favo']]); unset($_POST['favo']); } //タイムラインの識別 if (isset($_POST['timeline'])) { if ($_POST['timeline'] == 'home') { $TimeLine = 'home'; } else { $TimeLine = 'user'; } } else { $TimeLine = 'user';
$lastmonth_days = cal_days_in_month(CAL_GREGORIAN, $arr[$count - 2][1], $arr[$count - 2][0]); for ($i = 1; $i <= $lastmonth_days; $i++) { $lastmonth_kwh += (double) $arr[$count - $i][3]; } $lastmonth_kwh = round($lastmonth_kwh, 2); $tweetmsg .= "先月の使用電力量: {$lastmonth_kwh} kWh https://thingspeak.com/channels/48323 #ThingSpeak"; } else { $tweetmsg .= "https://thingspeak.com/channels/48323 #ThingSpeak"; } /*debug*/ var_dump($tweetmsg); } } /*ツイート*/ $consumer_key = "insert key"; $consumer_secret = "insert key"; $access_token = "insert key"; $access_token_secret = "insert key"; $connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); $statues = $connection->post("statuses/update", array("status" => $tweetmsg)); var_dump($statues); } /* ファイルポインタをクローズ */ fclose($file); /*独自関数の宣言*/ function fline(&$fp) { for ($total = 0; fgets($fp); $total++) { } return $total; }
<?php require "twitteroauth/autoload.php"; include "config.php"; include "db.php"; $database = new Database(); use Abraham\TwitterOAuth\TwitterOAuth; $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); $database->query('SELECT id,tweet,tweet_id from tweets WHERE sent=0'); $rows = $database->resultset(); $database->beginTransaction(); $database->query('UPDATE tweets SET sent = 1 where id = :id'); foreach ($rows as $tweet) { $result = $connection->post('statuses/update', array('in_reply_to_status_id' => $tweet['tweet_id'], 'status' => $tweet['tweet'])); print_r($result); if ($result->id > 0) { $database->bind(':id', $tweet['id']); $database->execute(); } } $database->endTransaction();
/** * Publish a message to the client * * @param string $provider_id * @param array $params * @param array $opts = [] * @return mixed */ public function post($provider_id, $params, $opts = []) { $this->prepareRequest($provider_id); $response = $this->client->post("statuses/update", $params); return $response->id_str; }
public function postTwitter($array) { $optionAppTwitter = get_option('twfc_app_twitter'); // realiza a conexão com o twiiter $connection = new TwitterOAuth($optionAppTwitter['twitterconsumer'], $optionAppTwitter['twitterconsumersecret'], $optionAppTwitter['twitteraccesstoken'], $optionAppTwitter['twitteraccesstokensecret']); $content = $connection->get("account/verify_credentials"); if (isset($content)) { if ($array['imagem']) { $media = $connection->upload('media/upload', array('media' => $array['imagem'])); $parameters = array('status' => $array['titulo'], 'media_ids' => $media1->media_id_string); } else { $parameters = array('status' => $array['titulo']); } $result = $connection->post('statuses/update', $parameters); return $result; } }