通过新浪博客API离线发布新浪博客,适合推广的同学用,可以一键批量群发新浪博客~直接上代码:
<?php
include_once ‘class-IXR.php’;//wordpress里的文件
function make_newpost($title, $content)
{
if (strlen($title) == 0) {
$title = ‘无题 ‘;
}
$wp2sinabloguser = ”;//博客帐号
$wp2sinablogpass = ”;//密码
if (strlen($wp2sinabloguser) > 4) {
if (strlen($wp2sinablogpass) > 5) {
$client->debug = false;
$xmlclient = ‘http://upload.move.blog.sina.com.cn/blog_rebuild/blog/xmlrpc.php’;
$client = new IXR_Client($xmlclient);
$content = htmlspecialchars_decode($content);
$catlog = array(‘前端知乎’);//新浪博客的分类名,没有可不填
$post1 = array(‘title’ => $title, ‘description’ => $content, ‘categories’ => $catlog );
$params = array(1, $wp2sinabloguser, $wp2sinablogpass, $post1, true);
$client->query(‘metaWeblog.newPost’, $params);
$wp2sinaid = $client->getResponse();
unset($client);
echo “<br>”.$name.$id.”success”;
}
}
}
$conn = @mysql_connect(‘localhost’, ‘root’, ”);//链接数据库,从数据库中读取内容
if (!$conn) {
die(‘连接数据库失败:’ . mysql_error());
}
mysql_select_db(‘book’, $conn);
mysql_query(‘SET NAMES \’utf8\”);
$ID = $_GET[‘id’];
$book = $_GET[‘name’];
$Query = “select * from content where BookName = ‘”.$book.”‘ and ID='”.$ID.”‘”;//sql语句
$Result = mysql_query($Query);
$Number = mysql_num_rows($Result);
for ($m = 0; $m < $Number; $m++) {
$Row = mysql_fetch_array($Result);
$title = $Row[‘Title’];
$content = $Row[‘Content’];
make_newpost($title, $content);
}
未经允许不得转载:前端撸码笔记 » 通过新浪博客API离线发布新浪博客,适合推广的同学用