2009年
11月24日
星期二
上個月介紹過用 Linux 系統自動發噗保卡馬。有人說他只有 Windows 可以用而已,所以這裡特地寫一篇用 Windows 實做的詳細步驟介紹供大家參考。
- 我們需要 PHP 。請到 AppServ 網站下載 AppServ 安裝檔並安裝。
- 啟用 cURL 模組。用記事本開啟 C:\Windows\php.ini ,找
extension=php_curl.dll
確認該行最前面沒有 ; 分號。如果有的話就把 ; 分號刪掉並存檔。
- 新增 plurkbot.php ,內容如下:
<?php header('Content-type:text/html; charset=utf-8'); define('NICKNAME', ''); //輸入 PLURK 的帳號 define('PASSWORD', ''); //輸入 PLURK 的密碼 $user_id = getid(NICKNAME); define('USER_ID', "$user_id"); set_time_limit(240); // login $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, '\plurk_cookie_n.txt'); curl_setopt($ch, CURLOPT_URL, 'http://www.plurk.com/Users/login'); curl_setopt($ch, CURLOPT_POSTFIELDS, 'nick_name='.NICKNAME.'&password='.PASSWORD); curl_exec($ch); curl_close($ch); // date_default_timezone_set("Asia/Taipei"); $out = date("Y-m-d H:i:s"); echo $out; post($out); function post($message){ // post $ch3 = curl_init(); curl_setopt($ch3, CURLOPT_COOKIEFILE, '\plurk_cookie_n.txt'); curl_setopt($ch3, CURLOPT_URL, 'http://www.plurk.com/TimeLine/addPlurk'); curl_setopt($ch3, CURLOPT_POSTFIELDS, 'qualifier=gives&limited_to=%5B'.USER_ID.'%5D&lang=tr_ch&uid='.USER_ID.'&no_comments=0&content='.$message); curl_exec($ch3); curl_close($ch3); } function getid($name){ $ourl= 'http://plurk.com/'.NICKNAME; $fid = file_get_contents($ourl); preg_match('/user_id\": (.*?)\,/s',$fid,$matches); $u_id = $matches[1]; return($u_id); } ?>別忘了設定帳號跟密碼的部份。如果你是使用 Windows 記事本存檔,請在輸入檔名畫面的「檔案類型」選擇「所有檔案」檔名才不會錯。確認一下 plurkbot.php 的位置,在這裡就以 C:\plurkbot\plurkbot.php 為例。
- 來測試一下剛剛寫好的檔案。執行 cmd 開啟命令提示字元,輸入指令:
C:\AppServ\php5\php.exe C:\plurkbot\plurkbot.php

出現像畫面中這樣的亂碼是正常的,不用擔心。接著開啟您的噗浪,檢查有沒有出現一則給自己,裡面寫著時間的私噗,有看到就是成功了。 - 之後再用 Windows 的工作排程,設定每四小時執行跟上一步驟相同的指令即可。
<?php
header('Content-type:text/html; charset=utf-8');
define('NICKNAME', ''); //輸入 PLURK 的帳號
define('PASSWORD', ''); //輸入 PLURK 的密碼
$user_id = getid(NICKNAME);
define('USER_ID', "$user_id");
set_time_limit(240);
// login
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, '\plurk_cookie_n.txt');
curl_setopt($ch, CURLOPT_URL, 'http://www.plurk.com/Users/login');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'nick_name='.NICKNAME.'&password='.PASSWORD);
curl_exec($ch);
curl_close($ch);
//
date_default_timezone_set("Asia/Taipei");
$out = date("Y-m-d H:i:s");
echo $out;
post($out);
function post($message){
// post
$ch3 = curl_init();
curl_setopt($ch3, CURLOPT_COOKIEFILE, '\plurk_cookie_n.txt');
curl_setopt($ch3, CURLOPT_URL, 'http://www.plurk.com/TimeLine/addPlurk');
curl_setopt($ch3, CURLOPT_POSTFIELDS, 'qualifier=gives&limited_to=%5B'.USER_ID.'%5D&lang=tr_ch&uid='.USER_ID.'&no_comments=0&content='.$message);
curl_exec($ch3);
curl_close($ch3);
}
function getid($name){
$ourl= 'http://plurk.com/'.NICKNAME;
$fid = file_get_contents($ourl);
preg_match('/user_id\": (.*?)\,/s',$fid,$matches);
$u_id = $matches[1];
return($u_id);
}
?>
5 Responses to “ Plurk 自動發噗保卡馬 (Windows) ”
Trackbacks & Pingbacks:
-
[...] (如果您只有 Windows 可用,這裡也有 Windows 系統的實做說明。) [...]

我想請問一下 如果我想要自己設定發噗內容(非報時噗)以及回噗內容,CODE要怎麼更改呢?
謝謝~
1. 設定發噗內容要改
$out = date("Y-m-d H:i:s");
這一行。以送出 "Hello world" 為例,請把那一行改成
$out = "Hello world";
如果想送出中文內容,檔案請以 UTF-8 編碼儲存。
2. 回噗的部份抱歉我沒有研究過。
您好,請問一下
您說的新增 plurkbot.php,是直接新增在C:\Windows\php.ini 還是另外開記事本新增呢?
還有我的PHP不是5是6耶 請問有影響嗎?
cURL模組怎麼開><
抱歉問題有點多,電腦白癡:P
plurkbot.php 是另外開記事本新增的。
PHP 版本沒差。
想啟用 cURL 模組,要修改 C:\Windows\php.ini 。打開 php.ini 搜尋 extension=php_curl.dll 並把前面的分號 ; 刪掉,跟上面第二步所寫的一樣。