不知道大家用过WP版的百度结构化插件没?老高就是研究了那个插件,观察其API,然后就写出了typecho版的。

为什么要改版呢?

百度站长最近推出新的接口,使用起来更简单,工作量不算大,索性就改改吧!

新版插件需要实现哪些功能?

文章实时推送
推送历史数据
站点地图
接口调用地址(API)在哪儿?

PHP接口实例:

$urls = array(
    'http://www.example.com/1.html',
    'http://www.example.com/2.html',
);
$api = 'http://data.zz.baidu.com/urls?site=www.phpgao.com&token=你的准入密钥';
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;