上個月介紹過用 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);
}
?>
請問要如何看到curl_exec($ch);的回傳值呢? 之前一直用自動發噗的,結果某天他忽然跟我說時timezone的設定有問題不能執行,後來就不能正常發噗了QQ 我當天的情況是
1.照常執行定時發噗
2.1小時後再發噗時忽然跳出『PHP Warning: strtotime(): It is not safe to rely on the system’s timezone settings. ….』接著就cmd會照常跳出,但都會出現這個警告而無法執行
3.去PHP.ini將『date.timezone』設定成 Asia/Taipei,之後警告消失,cmd可照常執行PHP,但依舊沒有發噗
4.後來用3個帳號來測試,只有其中1個有正常發噗,其餘兩個都執行卻無反應
有人跟我說可能是測試太多次被噗浪當成是Spam的關系…請問有什麼解決辦法嗎QQ?謝謝~
如果想要看 curl_exec($ch); 的回傳值,可以利用 var_dump() 函式。請試試看把 curl_exec($ch); 那一行改成 var_dump(curl_exec($ch)); 跑跑看,應該會在 DOS 視窗顯示出來。
另外被當成 Spam 的問題,我的經驗是過一段時間以後就會解除封鎖了。大概要等幾個小時吧?
我想請問一下 如果我想要自己設定發噗內容(非報時噗)以及回噗內容,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 並把前面的分號 ; 刪掉,跟上面第二步所寫的一樣。
Pingback: Plurk 自動發噗保卡馬 (Linux) « 小斌睡著了