Posteado el: 19/03/2009
por: Craftyman
Tags:
Twitter es un servicio gratuito de mensajería de utilidad social para mantenerse conectado en tiempo real.
Craftyman Blog también se unió a Twitter y pueden seguirlo aquí.
Aquí pongo un script de cómo usted puede actualizar su Twitter remotamente utilizando PHP.
public function updateTwitter($user,$pwd,$type,$msg)
{
$ruta = 'curl http://twitter.com/statuses/update.';
$msg = str_replace('"','\"',$msg);
$result = shell_exec($ruta.$type.' -u '.$user.':'.$pwd.' -d status="'.$msg.'"');
return $result;
}
$user = 'craftyman';
$pwd = '*********';
$type = 'xml'; //o 'json'
$msg = 'Actualizacion Twitter con PHP';
echo updateTwitter($user, $pwd, $type, $msg);
Retorno en Formato JSON
{
"user": {
"description": "PHP, MySQL, Javascript, CSS, Mootools, jQuery, Prototype",
"url": "http://craftyman.net",
"name": "Craftyman Blog",
"protected": false,
"followers_count": 3,
"profile_image_url":
"http://s3.amazonaws.com/twitter_production/profile_images/98739091/facivon_normal.jpg",
"location": "",
"id": 24746352,
"screen_name": "craftyman"
},
"text": "Actualizar Twitter con PHP",
"favorited": false,
"created_at": "Thu Mar 19 17:04:56 +0000 2009",
"in_reply_to_status_id": null,
"truncated": false,
"in_reply_to_user_id": null,
"id": 1355417660,
"in_reply_to_screen_name": null,
"source": "web"
}
Retorno en Formato XML
<?xml version="1.0" encoding="UTF-8"?>
<status>
<created_at>Thu Mar 19 17:06:31 +0000 2009</created_at>
<id>1355426342</id>
<text>Actualizar Twitter con PHP y XML</text>
<source>web</source>
<truncated>false</truncated>
<in_reply_to_status_id></in_reply_to_status_id>
<in_reply_to_user_id></in_reply_to_user_id>
<favorited>false</favorited>
<in_reply_to_screen_name></in_reply_to_screen_name>
<user>
<id>24746352</id>
<name>Craftyman Blog</name>
<screen_name>craftyman</screen_name>
<location></location>
<description>PHP, MySQL, Javascript, CSS, Mootools, jQuery, Prototype</description>
<profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/98739091/facivon_normal.jpg</profile_image_url>
<url>http://craftyman.net</url>
<protected>false</protected>
<followers_count>3</followers_count>
</user>
</status>





June 30th, 2009 at 4:28 am
muy bueno
September 23rd, 2009 at 1:00 pm
Y que hago con el xml generado un poco de mas luces por favor somos unos novatos