看板 java 關於我們 聯絡資訊
以下分享我的使用心得: 官方提供的 Java 範例碼: http://www.plurk.com/API/issueKey#java_example API key 申請網址:http://www.plurk.com/API 下載 Apache's HttpClient Library:http://hc.apache.org/httpcomponents-client/ 範例碼需要修改的地方: 一、 private static String API_KEY = "dKkIdUCoHo7vUDPjd3zE0bRvdm5a9sQi"; 要把 dKkIdUCoHo7vUDPjd3zE0bRvdm5a9sQi 換成自己申請到的 API key, 二、 HttpGet httpget = new HttpGet(getApiUri("/Users/login?"+ "api_key=" + API_KEY + "&" + "username=" + "user_x" + "&" + "password=" + "user_x_pw" )); user_x 與 user_x_pw 要用自己實際的 Plurk 帳號/密碼取代, 而且在執行程式前,要先登入自己的 Plurk。 三、 httpget = new HttpGet(getApiUri("/Timeline/plurkAdd?"+ "api_key=" + API_KEY + "&" + "content=" + "Plurk+API+測試" + "&" + "qualifier=" + "says" + "&" + "qualifier_translated=" + "" + "&" + "lang=tr_ch" )); content:要發送的訊息 qualifier:設定英文的修飾語,例如:says, likes, shares, gives... 等 qualifier_translated:將英文的修飾語改成其它語言的修飾語 lang:設定修飾語的語言,en代表英文,tr_ch代表正體中文 這樣就可以正常執行程式了 = = -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.44.7.126 ※ 編輯: erotic 來自: 114.44.7.126 (12/28 00:52) ※ 編輯: erotic 來自: 114.44.7.126 (12/28 00:52)
askeing:執行程式前應該不用先登入,直接在程式內登入應該就行了 12/30 16:06
askeing:要送的訊息則建議都先處理一下再送出去 12/30 16:08
erotic:把帳號/密碼放在程式裡很不安全,有比較安全的作法嗎? = = 12/30 21:43
askeing:可以從程式裡面抓 property file 內的資料,可以手動輸入 12/31 15:34