Last active
June 21, 2018 16:56
-
-
Save invmatt/5772289 to your computer and use it in GitHub Desktop.
Simple PHP Twitter AUTH. You'll need to include https://github.com/abraham/twitteroauth for OAuth
This file contains hidden or 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 | |
| session_start(); | |
| require_once("twitteroauth/twitteroauth/twitteroauth.php"); //Path to twitteroauth library | |
| $twitteruser = "twitterusername"; | |
| $notweets = 30; | |
| $consumerkey = "12345"; | |
| $consumersecret = "123456789"; | |
| $accesstoken = "123456789"; | |
| $accesstokensecret = "12345"; | |
| function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) { | |
| $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret); | |
| return $connection; | |
| } | |
| $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret); | |
| $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets); | |
| echo json_encode($tweets); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment