Created
January 5, 2019 11:06
-
-
Save gioxx/5149ce4058308f85e440c14870873c5b to your computer and use it in GitHub Desktop.
Uno script PHP che ti permette di pubblicare un tweet contenente un countdown di giorni generato tramite timercheck.io, maggiori informazioni su https://wp.me/pdQ5q-9YA
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_once "autoload.php"; | |
use Abraham\TwitterOAuth\TwitterOAuth; | |
// API @TUOACCOUNTTWITTER | |
define('CONSUMER_KEY', 'XXX'); | |
define('CONSUMER_SECRET', 'XXX'); | |
define('ACCESS_TOKEN', 'XXX'); | |
define('ACCESS_TOKEN_SECRET', 'XXX'); | |
$json = file_get_contents('https://timercheck.io/Test-Gioxx.org/60'); | |
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |
// Credits for json decode: https://stackoverflow.com/questions/15617512/get-json-object-from-url | |
$obj = json_decode($json); | |
if ($obj->status == "ok") { | |
$secondi = $obj->seconds_remaining; | |
$giorni = $secondi / 86400; | |
$status = 'Countdown ⏰: -'.round($giorni).'. Buongiorno! ☕'; //text for your tweet. | |
$post_tweets = $connection->post("statuses/update", ["status" => $status]); | |
} else { | |
$status = 'Buongiorno! ☕'; //text for your tweet. | |
$post_tweets = $connection->post("statuses/update", ["status" => $status]); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment