Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a76ed534cb
Fetching contributors…

Cannot retrieve contributors at this time

file 27 lines (18 sloc) 0.847 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php

require_once dirname(__FILE__) . "/lib/TwitterOAuth.php";

function shortenUrl($url){
    return file_get_contents("http://is.gd/create.php?format=simple&url=".urlencode($url));
}

$config = parse_ini_file('config.ini', true);
$payload = getPayload();

$message = $payload->message;
$message .= "\n";
$message .= shortenUrl($payload->url);

$connection = new TwitterOAuth( $config['twitter']['consumer_key'],
                                $config['twitter']['consumer_secret'],
                                $config['twitter']['oauth_token'],
                                $config['twitter']['oauth_secret']);

$content = $connection->get('account/verify_credentials');

$status = $connection->post('statuses/update', array('status' => $message));

print_r($status);

# You can see posted message at https://twitter.com/#!/WorkerPHP
Something went wrong with that request. Please try again.