Skip to content

Instantly share code, notes, and snippets.

@pvalencia
Created August 12, 2009 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvalencia/166672 to your computer and use it in GitHub Desktop.
Save pvalencia/166672 to your computer and use it in GitHub Desktop.
twiteando con cakephp
<?php
function tweet($status) {
$username = 'TWITTER_USERNAME';
$password = 'TWITTER_PASSWORD';
App::import('Core', array('Xml', 'HttpSocket'));
$sckt = new HttpSocket();
$res = $sckt->request(
array(
'method' => 'POST',
'uri' => array(
'scheme' => 'http',
'host' => 'twitter.com/statuses/update.xml',
'query' => array('status' => $status)
),
'auth' => array(
'method' => 'Basic',
'user' => $username,
'pass' => $password,
),
'header' => array(
'X-Twitter-Client' => 'TWITTER_CLIENT'
)
)
);
if(!$res)
return false;
$xml = new Xml($res);
$xml = Set::reverse($xml); // CakeMagic!!!!!!!
return $xml;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment