Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
<?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
You can’t perform that action at this time.