Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active June 29, 2017 11:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/181738 to your computer and use it in GitHub Desktop.
Save pingyen/181738 to your computer and use it in GitHub Desktop.
Plurk Bot with Reply
<?php
define('NICKNAME', 'abc');
define('PASSWORD', 'iamabc');
define('USER_ID', '123456');
$message = 'Hello World!';
$reply = 'I am ABC!';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
// login
curl_setopt($ch, CURLOPT_URL, 'https://www.plurk.com/login');
$response = curl_exec($ch);
$pos_s = strpos($response, '<input type="hidden" name="login_token" value="') + 47;
$token = substr($response, $pos_s, strpos($response, '"', $pos_s) - $pos_s);
curl_setopt($ch, CURLOPT_URL, 'https://www.plurk.com/Users/login');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'nick_name='.NICKNAME.'&password='.PASSWORD.'&login_token=' . $token);
curl_exec($ch);
// post
curl_setopt($ch, CURLOPT_URL, 'https://www.plurk.com/TimeLine/addPlurk');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'qualifier=says&content='.urlencode($message).'&lang=tr_ch&no_comments=0&uid='.USER_ID);
$response = curl_exec($ch);
$pos_s = strpos($response, '"plurk_id":') + 11;
$plurk_id = substr($response, $pos_s, strpos($response, ',', $pos_s) - $pos_s);
// reply
curl_setopt($ch, CURLOPT_URL, 'https://www.plurk.com/Responses/add');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'content='.urlencode($reply).'&replurk_id=&lang=tr_ch&p_uid='.USER_ID."&plurk_id=$plurk_id&posted=".date('c').'&qualifier=says&uid='.USER_ID);
curl_exec($ch);
curl_close($ch);
?>
@pingyen
Copy link
Author

pingyen commented May 11, 2015

@pingyen
Copy link
Author

pingyen commented Feb 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment