Created
October 21, 2017 11:00
-
-
Save gorkamu/a8fc407542d2b50caa5ebbfc310d523d to your computer and use it in GitHub Desktop.
PHP middleware dash button
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