Skip to content

Instantly share code, notes, and snippets.

@pingyen

pingyen/plurkBot2.php

Last active Jun 29, 2017
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@pingyen pingyen commented May 11, 2015

@pingyen

This comment has been minimized.

Copy link
Owner Author

@pingyen pingyen commented Feb 19, 2017

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