顯示具有 PLURK 標籤的文章。 顯示所有文章
顯示具有 PLURK 標籤的文章。 顯示所有文章

2009年9月6日 星期日

PLURK BOT 範例

這是一個以 自由時報即時新聞 為基礎建立的 php plurk bot 範例
會貼出最新的10條新聞


2009年4月20日 星期一

原來,Plurk 是用 Python 寫的

今天 Plurk時
出現了錯誤訊息
原來 Plurk 是用爬說語寫的

plurk_error

2009年4月18日 星期六

[PHP 筆記] 發個私噗給自己

沒事發私噗給自己?

雖然 PLURK 有假期模式
但想保卡馬又沒時間噗浪
也不想造成他人的困擾
就想寫個程式
搭配 Windows xp '排定的工作'
成為定時發私噗的噗浪機器人
而這個私噗的內容只有自己可看到。

 

plurk_limit.php

 

<?
header('Content-type:text/html; charset=utf-8');
define('NICKNAME', ''); //輸入 PLURK 的 NICKNAME
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);
}

?>



 



 



上面

define ('NICKNAME', '1234'); 1234 改為你 PLURK 的 NICKNAME
define ('PASSWORD','5678'); 5678 改為你 PLURK 的密碼
如果噗同樣的內容
可能會被 Plurk 的防洪機制所阻擋
所以我把它設定為報時噗
排程的方式

以 AppServ 為例


首先要讓 php 支援 cURL 模組


 


我的排程是執行
D:\AppServ\php5\php.exe D:\AppServ\www\plurk\test\plurk_limit.php

limit



切記!
每日超過 30 噗主題是會扣卡馬的
所以重複執行時間可不能設定太短喔。

 


順便打個小廣告
歡迎加入我的 機器人噗浪

.



[PHP 筆記]查詢某 PLURK NICKNAME 的 user id

 
首先要定義程式中的 NICKNAME
如我的 NICKNAME
define('NICKNAME', 'never4get');
 
<?
define('NICKNAME', ''); // 在 '' 中輸入要查詢的 NICKNAME
$user_id = getid(NICKNAME);
echo $user_id;

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);
}

?>