标签 Twitter 下的文章

导入twitter数据到wordpress

twitter的备份工具很多,tweet backup,tweettake,导出的格式有txt,csv,没有我想要的sql脚本。所以使用这个使用这个项目的代码:http://code.google.com/p/tbackup/
将proccess.php的第75行到97行的代码修改为:

//$text = iconv('UTF-8', CHARSET, $status->text);
//$text = str_replace('"', '""', $text);
//fwrite($file, $datestr . '$$$' . $status->id . '$$$' . $text . '$$$' . chr(13) . chr(10));
$text = $status->text;
$link_id = mysql_connect("localhost", "user", "pass") or
die("Could not connect: " . mysql_error());
mysql_select_db('wpdb');
mysql_query("set names utf8");
 
$title = substr($text, 0, 60);
 
$sql = "INSERT INTO `jq_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`,
`post_category`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`,
`pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`,
`post_mime_type`, `comment_count`)
VALUES (NULL, '1', '$datestr', CONVERT_TZ('$datestr','+08:00','+00:00'), '$text', '$title', '0', '', 'publish', 'open', 'open', '', unix_timestamp('$datestr'), '', '',
'$datestr',CONVERT_TZ('$datestr','+08:00','+00:00') , '', '0', unix_timestamp('$datestr'), '0', 'post', '', '0');";
mysql_query($sql);
$insert_id = mysql_insert_id($link_id);
mysql_query("insert into wp_term_relationships values ($insert_id,770,0) "); //将770改为对应的term_taxonomy_id
mysql_query("update wp_term_taxonomy set count=count+1 where term_taxonomy_id=770 ");//将770改为对应的term_taxonomy_id 

将所有代码上传到网站目录,输入twitter ID,点Start,等待一段时间,所有数据就导入了wordpress。

至此搞了四天,将饭否,嘀咕,twitter的数据都导入到了wordpress博客之中。所有的微博数据在 http://tunps.com/tag/microblogging