Last active
December 16, 2016 12:43
-
-
Save mrl22/f41b008525c92d321c382d0b287b6d6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Dont forget to load twitter oauth via Composer | |
$twitteruser = 'webfwd'; | |
$tweetexpire = 60 * 30; // Seconds | |
$tweetfile = 'twitter.txt'; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
if (!file_exists($tweetfile) || (time()-filemtime($tweetfile)) > $tweetexpire) { | |
$connection = new TwitterOAuth( | |
"", // API Key | |
"", // API Secret | |
"", // Access Token | |
"" // Access Token Secret | |
); | |
$content = $connection->get("account/verify_credentials"); | |
$statuses = $connection->get('statuses/user_timeline', array('screen_name' => $twitteruser, 'exclude_replies' => 'true', 'include_rts' => 'false', 'count' => 1)); | |
$tweet = $statuses[0]->text; | |
file_put_contents($tweetfile, $tweet); | |
} else $tweet = file_get_contents($tweetfile); | |
echo $tweet; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment