Created
February 1, 2016 13:03
-
-
Save nothingatalldotnet/571aa284d2c1d7b07d51 to your computer and use it in GitHub Desktop.
Simple get twitter feed...
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 | |
require "social-feed-resources/twitteroauth/autoload.php"; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
$twitter_customer_key = '_KEY_'; | |
$twitter_customer_secret = '_SECRET_'; | |
$twitter_access_token = '_ACCESS_'; | |
$twitter_access_token_secret = '_SECRET_TOKEN'; | |
$tweet_count = 10; | |
function makeClickableLinks($s) { | |
return preg_replace('@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a target="blank" rel="nofollow" href="$1" target="_blank">$1</a>', $s); | |
} | |
$connection = new TwitterOAuth($twitter_customer_key, $twitter_customer_secret, $twitter_access_token, $twitter_access_token_secret); | |
$tweets = $connection->get('statuses/user_timeline', array('screen_name' => 'nothingatallnet', 'count' => $tweet_count)); | |
for($i=0; $i<$tweet_count; $i++) { | |
$this_tweet = $tweets[$i]; | |
echo "<div class\"twitter\">"; | |
echo makeClickableLinks($this_tweet->text); | |
echo "</div>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment