下面提供一些推送示例
curl版本推送示例
curl -H 'Content-Type:text/plain' --data-binary @urls.txt "http://data.zz.baidu.com/urls?site=www.chinaadmin.cn&token=Q0oQphKxqxVLrblQ"
php版本推送示例
= array(
'http://www.example.com/1.html',
'http://www.example.com/2.html',
);
= 'http://data.zz.baidu.com/urls?site=www.chinaadmin.cn&token=Q0oQphKxqxVLrblQ';
= curl_init();
= array(
CURLOPT_URL => ,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n", ),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array(, );
= curl_exec();
echo ;
ruby推送示例
require 'net/http'
urls = ['http://www.example.com/1.html', 'http://www.example.com/2.html']
uri = URI.parse('http://data.zz.baidu.com/urls?site=www.chinaadmin.cn&token=Q0oQphKxqxVLrblQ')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = urls.join("\n")
req.content_type = 'text/plain'
res = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
puts res.body
post版本推送示例
POST /urls?site=www.chinaadmin.cn&token=Q0oQphKxqxVLrblQHTTP/1.1
User-Agent: curl/7.12.1
Host: data.zz.baidu.com
Content-Type: text/plain
Content-Length: 83
http://www.example.com/1.html
http://www.example.com/2.html