Skip to content

Instantly share code, notes, and snippets.

@Daltontastic
Last active February 28, 2017 08:36
Show Gist options
  • Save Daltontastic/e4b5e92a55905e604dc1381e9926d2a4 to your computer and use it in GitHub Desktop.
Save Daltontastic/e4b5e92a55905e604dc1381e9926d2a4 to your computer and use it in GitHub Desktop.
Download cacert.pem and codebird.php from https://github.com/jublonet/codebird-php/tree/develop/src
<?php
function tweet($tweet)
{
define("CONSUMER_KEY", "apps.twitter.com");
define("CONSUMER_SECRET", "apps.twitter.com");
define("ACCESS_TOKEN", "apps.twitter.com");
define("ACCESS_SECRET", "apps.twitter.com");
require_once("codebird.php");
\Codebird\Codebird::setConsumerKey(CONSUMER_KEY, CONSUMER_SECRET);
$cb = \Codebird\Codebird::getInstance();
$cb->setToken(ACCESS_TOKEN, ACCESS_SECRET);
$params = array(
"status" => $tweet
);
$reply = $cb->statuses_update($params);
$data = (array) $reply;
if (isset($data["created_at"])) {
return true;
} else {
return false;
}
}
$tweet = tweet("Hi @Daltontastic");
if ($tweet) {
echo "Tweeted";
} else {
echo "Not Tweeted";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment