Last active
August 29, 2015 14:28
-
-
Save davidkryzaniak/c54bc9fc5b05ad7eefe3 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 | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
$ua = $_SERVER['HTTP_USER_AGENT']; | |
//User agent must be set to "**MY-SECRET-USER-AGENT**" and the ?secret must be "key" | |
if("**MY-SECRET-USER-AGENT**" == $ua && isset($_GET['secret']) && "key" == $_GET['secret']){ | |
// Load Composer | |
require_once('../vendor/autoload.php'); | |
//if the type is set to "twitter" and the msg is not empty | |
if(isset($_GET['type']) && "twitter" == $_GET['type'] && isset($_GET['msg']) && !empty($_GET['msg'])){ | |
//prepend a timestamp to the message | |
$message = '['.date('Y-m-d H:i:s').'] '.urldecode($_GET['msg']); | |
// Using dg's twitter library - https://github.com/dg/twitter-php | |
$twitter = new Twitter( | |
'ConsumerKey', | |
'ConsumerSecret', | |
'AccessToken', | |
'AccessTokenSecret' | |
); | |
//post it to Twitter | |
$twitter->send($message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment