Skip to content

Instantly share code, notes, and snippets.

@ssx
Created September 24, 2010 20:33
Show Gist options
  • Save ssx/595992 to your computer and use it in GitHub Desktop.
Save ssx/595992 to your computer and use it in GitHub Desktop.
<?php
// Twitter Status Update via Oauth
// By Scott Wilcox (v0.1) http://dor.ky
require "lib/EpiCurl.php";
require "lib/EpiOAuth.php";
require "lib/EpiTwitter.php";
// You need to fetch these OAuth tokens and save them for use
// within the OAuth calls. To get these values you will need
// to create a new 'app' at http://dev.twitter.com/apps
//
// You can find CONSUMER_KEY and CONSUMER_SECRET on your apps
// 'Application Details' page, and you can find USER_TOKEN and
// USER_SECRET on the 'My Access Token' page.
define(CONSUMER_KEY,"Replace with your Consumer Key");
define(CONSUMER_SECRET,"Replace with your Consumer Secret");
define(USER_TOKEN,"Replace with 'My Access Token' Oauth token");
define(USER_SECRET,"Replace with 'My Access Token' Oauth secret");
// If there was a command line argument passed, we can use that as
// the status update text, else print an error out
$text = "My status update goes here";
$twitterObj = new EpiTwitter(CONSUMER_KEY,CONSUMER_SECRET,USER_TOKEN,USER_SECRET);
$x = $twitterObj->post_statusesUpdate(array('status' => utf8_encode($text)));
if ($x->id) {
echo "Tweet Posted: ".$x->id."\n";
} else {
echo "Error Posting Tweet\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment