User Tools

Site Tools


Sidebar



twitter

Twitter

twitter from the command line
twitter stream with curl

create a file called 'tracking' with this text in it (searching for the word 'twitter'):

track=twitter
curl -d @tracking https://stream.twitter.com/1/statuses/filter.json -ucompanje:
get twitter status in php without oAuth
load last tweet
$url = "http://twitter.com/statuses/user_timeline/".USER_ID.".xml?count=1";
$xml = simplexml_load_file($url) or die("could not connect");
foreach($xml->status as $status) $result = $status;
get status or update status with oAuth

using: https://github.com/abraham/twitteroauth

require_once 'twitteroauth/twitteroauth.php';
 
define("CONSUMER_KEY", "xxxx");
define("CONSUMER_SECRET", "xxxx");
define("OAUTH_TOKEN", "xxxx");
define("OAUTH_SECRET", "xxxx");
 
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET);
 
if (isset($_POST["txt"])) {
	//update tweet 
	$content = $connection->get('account/verify_credentials');
	$content = $connection->post('statuses/update', array('status'=>$txt)); //date(DATE_RFC822))
	$result = gmstrftime("%e %B %H:%M ",time()+3600) . " - $txt";
} else {
	//get status
	$content = $connection->get('statuses/user_timeline');
	$result = $content[0];
	$date = strtotime($result->created_at);
	$result = gmstrftime("%e %B %H:%M ",$date+3600) . " - {$result->text}";
}
Follow me

Links to this page

twitter.txt · Last modified: 2014/11/23 16:33 (external edit)