Created
June 4, 2014 08:03
-
-
Save Andrew-Spiers/143311ab52ec379569ba to your computer and use it in GitHub Desktop.
This script will email you any tweet which you have marked as a favourite then it unfavourites it. There are 2 prerequisites; http://www.gabfirethemes.com/create-twitter-api-key/ and https://github.com/abraham/twitteroauth
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('libraries/twitteroauth.php'); | |
$conkey = ''; | |
$consec = ''; | |
$acctok = ''; | |
$acctks = ''; | |
$twitter = new TwitterOAuth($conkey, $consec, $acctok, $acctks); | |
$tweets = $twitter->get('https://api.twitter.com/1.1/favorites/list.json?screen_name=yourscreenname'); | |
if (sizeof($tweets) > 0) { | |
foreach ($tweets as $tweet) { | |
$screenName = $tweet->user->screen_name; | |
$userName = $tweet->user->name; | |
$tweetMsg = $tweet->text; | |
$tweetID = $tweet->id_str; | |
$emailTitle = "Tweet from $userName (@$screenName)"; | |
$emailMSG = wordwrap($tweetMsg, 70, "\r\n"); | |
$status = mail('emailrecipientgoeshere', $emailTitle, $emailMSG); | |
if ($status) { | |
$unfav = $twitter->post('https://api.twitter.com/1.1/favorites/destroy.json?id='.$tweetID); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment