Ping百度自动提交网址

<?php
    function postUrl($url,$postvar){
        $ch = curl_init();
        $headers = array(
                "POST".$url."HTTP/1.0",
                "Content-type: text/xml;charset=\"utf-8\"",
                "Accept: text/xml",
                "Content-length:".strlen($postvar)
            );
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$postvar);
        $res = curl_exec($ch);
        curl_close($ch);
        return $res;
    }
    $baiduXML = "<?xml varsion=\"1.0\"> encoding=\"utf-8\"?>
                <methodCall>
                    <methodName>weblogUpdates.extendedPing</methodName>
                    <params>
                        <params><value>新浪新闻</value></params>
                        <params><value><string>http://wwww.wwww.com/index.php</string></value></params>
                        <params><value><string>http://wwww.wwww.com/index.php/html_1.html</string></value></params>
                        <params><value><string>http://wwww.wwww.com/index.php/html_2.html</string></value></params>
                        <params><value><string>http://wwww.wwww.com/index.php/html_3.html</string></value></params>
                    </params>
                </methodCall>
    ";
    $res = postUrl(\'http://ping.baidu.com/ping/RPC2\',$baiduXML);

    var_dump($res);

 

版权声明:本文为shanyansheng原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/shanyansheng/p/5488358.html