Skip to content

Instantly share code, notes, and snippets.

@davidkryzaniak
Last active August 29, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidkryzaniak/c54bc9fc5b05ad7eefe3 to your computer and use it in GitHub Desktop.
Save davidkryzaniak/c54bc9fc5b05ad7eefe3 to your computer and use it in GitHub Desktop.
<?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