function reply_tweet($tweetID, $message) { $connection = new TwitterOAuth(TWITTER_KEY, TWITTER_SECRET, TWITTER_TOKEN, TWITTER_TOKEN_SECRET); $response = $connection->post("statuses/update", array("in_reply_to_status_id" => $tweetID, "status" => $message)); if (isset($response->errors)) { var_dump($response->errors); return false; } else { return $response->id; } }
echo "Get Screenname\r\n"; $response = $tw->get("account/settings"); $screenName = $response->screen_name; $conf->setValue("screenName", $screenName); } $lists = new Lib\Lists(); if ($lastid !== false) { $response = $tw->get('statuses/mentions_timeline', array("since_id" => $lastid)); } else { $response = $tw->get('statuses/mentions_timeline', array()); } # Loop Tweets foreach ($response as $tweet) { # Set lastid if tweet id is bigger if ($tweet->id_str > $lastid) { $lastid = $tweet->id_str; } #Tweet Pharsen list($listname, $entrys) = $lists->tweetPhrasen($tweet->text); if (!$lists->checkNewUser($tweet->user->id_str)) { $lists->addUser($tweet->user->id_str); $follow = $tw->get("friendships/lookup", array("user_id" => $tweet->user->id_str)); if (!in_array("followed_by", $follow[0]->connections)) { $tw->post("statuses/update", array("status" => "@" . $follow[0]->screen_name . " folge mir dann schicke ich dir deine Listen zugangsdaten per DM.", "in_reply_to_status_id" => $tweet->id_str)); } } foreach ($entrys as $entry) { $lists->addEntrie($tweet->user->id_str, $entry, $listname); } } $conf->setValue("lastid", $lastid);
/* statuses/mentions */ twitteroauth_row('statuses/mentions', $connection->get('statuses/mentions'), $connection->http_code); /* statuses/retweeted_by_me */ twitteroauth_row('statuses/retweeted_by_me', $connection->get('statuses/retweeted_by_me'), $connection->http_code); /* statuses/retweeted_to_me */ twitteroauth_row('statuses/retweeted_to_me', $connection->get('statuses/retweeted_to_me'), $connection->http_code); /* statuses/retweets_of_me */ twitteroauth_row('statuses/retweets_of_me', $connection->get('statuses/retweets_of_me'), $connection->http_code); /** * Status Methods. */ twitteroauth_header('Status Methods'); /* statuses/update */ date_default_timezone_set('GMT'); $parameters = array('status' => date(DATE_RFC822)); $status = $connection->post('statuses/update', $parameters); twitteroauth_row('statuses/update', $status, $connection->http_code, $parameters); /* statuses/show */ $method = "statuses/show/{$status->id}"; twitteroauth_row($method, $connection->get($method), $connection->http_code); /* statuses/destroy */ $method = "statuses/destroy/{$status->id}"; twitteroauth_row($method, $connection->delete($method), $connection->http_code); /* statuses/retweet */ $method = 'statuses/retweet/6242973112'; twitteroauth_row($method, $connection->post($method), $connection->http_code); /* statuses/retweets */ $method = 'statuses/retweets/6242973112'; twitteroauth_row($method, $connection->get($method), $connection->http_code); /** * User Methods.
date_default_timezone_set('UTC'); /** * Array with the OAuth tokens provided by Twitter when you create application * * output_format - Optional - Values: text|json|array|object - Default: object */ $config = array('consumer_key' => '01b307acba4f54f55aafc33bb06bbbf6ca803e9a', 'consumer_secret' => '926ca39b94e44e5bdd4a8705604b994ca64e1f72', 'oauth_token' => 'e98c603b55646a6d22249d9b0096e9af29bafcc2', 'oauth_token_secret' => '07cfdf42835998375e71b46d96b4488a5c659c2f', 'output_format' => 'object'); /** * Instantiate TwitterOAuth class with set tokens */ $tw = new TwitterOAuth($config); /** * Returns a collection of the most recent Tweets posted by the user * https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline */ $params = array('screen_name' => 'ricard0per', 'count' => 5, 'exclude_replies' => true); /** * Send a GET call with set parameters */ $response = $tw->get('statuses/user_timeline', $params); var_dump($response); /** * Creates a new list for the authenticated user * https://dev.twitter.com/docs/api/1.1/post/lists/create */ $params = array('name' => 'TwOAuth', 'mode' => 'private', 'description' => 'Test List'); /** * Send a POST call with set parameters */ $response = $tw->post('lists/create', $params); var_dump($response);
<?php use TwitterOAuth\TwitterOAuth; date_default_timezone_set('UTC'); require_once __DIR__ . '/vendor/autoload.php'; include "config/config.php"; $tw = new TwitterOAuth($config); $conf = new Lib\Conf(); //Last ID $lastid = $conf->getValue("lastid"); $lists = new Lib\Lists(); $entrys = $lists->getShortKeys(); foreach ($entrys as $entry) { #$user = $tw->get("users/lookup", array("user_id"=>$entry["userid"])); #$username = $user[0]->screen_name; $tw->post("direct_messages/new", array("user_id" => $entry["userid"], "text" => "Dein Key ist " . $entry["shortkey"] . "")); $lists->createLongKey($entry["userid"]); #var_dump($user); }
//var_dump($ret); //return $response->id; } } } else { var_dump($ret); } */ $ret = db_query("Twitter_Follower", array("UserID"), "request_friend = 0 AND last_update < '" . date('Y-m-d H:i:s', strtotime('-3 days')) . "' LIMIT 150"); //var_dump($ret); if (!$ret->{'Status'}) { foreach ($ret->{'Results'} as $item) { $friend = $connection->post("friendships/destroy", array("user_id" => $item->{'UserID'})); if (isset($friend->errors)) { var_dump($friend->errors); } else { $ret = db_delete("Twitter_Follower", array("UserID" => $item->{'UserID'})); var_dump($ret); } } } else { var_dump($ret); } /* $ret = db_query("Twitter_Tweet", array("TweetID"), null); if (!$ret->{'Status'}) { foreach ($ret->{'Results'} as $item)