paip.百度空間 JAVA程式發文總結

來源:互聯網
上載者:User

paip.百度空間 JAVA程式發文總結

GP百度空間不支援用戶端,只好自己開發了。。

使用HTTPCLIENT,COOKIE超長,先把它儲存在檔案裡,然後讀取。。自動斷行,需要

REPLACE掉換行..不然報400錯..

 

發文-------------------

POST /pub/submit/createtext HTTP/1.1

樣本
http://hi.baidu.com/pub/submit/createtext?

title=title24&content=txt24&private=0&imgnum=0&bdstoken=3a6bd382df05333ef96

3838cfa28f0d7&qbid=&refer=http:%2F%2Fhi.baidu.com

%2Fhome&private1=0&qing_request_source=

返回JSON
{"errorNo" : "501","errorMsg" : "user not login","data": [ ]}

每次返回時會重設BDSP , BDSTAT 這兩個COOKIE值..需要注意,雖然不重設這兩個值也可以

發文,不過發的HTML全部被轉碼了。。顯示源碼出來了。。

------------------------------------發送內容的URL轉碼----------
因為是通過 application/x-www-form-urlencoded");  發送,所以發送內容需要進行URL編碼..

但是其中的漢字必須是UTF-8編碼,在這裡,漢字不能URL編碼。。。與標準編碼不同的是,百度

空間對問號不進行轉碼..所以,根據漢字UTF8編碼,其它進行URL編碼,所以不能和

title=java.net. URLEncoder.encode這個,只能自己編寫轉碼方法了,只對特殊符號進行轉碼,

除問號外...。。。

  //dsi shha baidu konjye
     //ati 2012.7.14
     public static String urlEncode(String content) {
     if(content==null) return "";       
        String html = content;
        
        html = html.replace( "%", "%25");  //"
        html = html.replace( "+", "%2B");
        html = html.replaceAll( " ", "%20");
        html = html.replace( "/", "%2F");  //"
   //     html = html.replace( "?", "%3F");  //"ngaidaolei

yao url endcode ,baidu konjye d byao .
       
     
        html = html.replace( "#", "%23");  //"
        html = html.replace( "&", "%26");  //"
        html = html.replace( "=", "%3D");  //"
        
          
        return html;
     }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.