Script Example: Automation tweets posting using Human Emulator Studio

Example of automation scripts (PHP, C#, Java Script sand Phyton) and tutorials.
Post Reply
User avatar
support
Site Admin
Posts: 65
Joined: Fri Feb 22, 2019 3:42 pm

Script Example: Automation tweets posting using Human Emulator Studio

Post by support » Thu Apr 04, 2019 7:55 pm

What the script does: Posting tweets from file tweets.txt to twitter.com. One line one tweet.

Script code:

<?php
/*  Type: PHP Example of script 
**  Do: Post twitts
**  software version: Human Emulator Studio
**  site: webemulator.com
**  discuss: webemulator.com/forum/viewforum.php?f=7
*/

$xhe_host ="127.0.0.1:7010";

// The following code is required to properly run XWeb Human Emulator
require("../../Templates/xweb_human_emulator.php");

// //////////////////////// scripts settings /////////////////////////
// account data
// login
$str_lg_tw="DmitriyDumanovs";
// password
$str_pass_tw="kuvxplscgQQ4110";
// path to file with tweets
$path_to_tws = "data/tweets.txt";
// pause between post tweets (sec)
$wt_min="10";
$wt_max="15";

// pause between actions
$wt =1;
// debug mode
$dbg = true;

// //////////////////////// addition modules ///////////////
// addition functions 
require_once("tools/functions.php");

// /////////////////////// script actions ///////////////////////////////////////////
debug_mess("Script started.");

// get twits to array
$a_tws= file($path_to_tws);

debug_mess("login to twitter.com");
// login to twitter.com
if(!login_tw($str_lg_tw, $str_pass_tw))
{
   debug_mess("Can't login! Please check account data. Script stop.");
   $app->quit();
}

debug_mess("post all twts from file");
// post all twits from file
foreach($a_tws as $tweet )
{
    // skip empty
	if($tweet=="")
     continue;

	// post
    $div->click_by_id("tweet-box-home-timeline");
    sleep($wt);
    $div->send_keyboard_input_by_attribute("id", "tweet-box-home-timeline", true,$tweet, "20:40");
    sleep($wt);
    $btn->click_by_inner_html("<span class=\"button-text tweet", false);
    sleep($wt);
    $mouse->send_wheel(1,100,100);
    //$btn->click_by_attribute("class", "button-text tweeting-text", true);

    // get random pause
    $wt_post = rand($wt_min,$wt_max);

    debug_mess("wait $wt_post seconds and post next tweet");
	sleep($wt_post);
}

debug_mess("Script finished.");

// Quit
$app->quit();
?>

Video how script works:
phpBB [video]


Download script:
post_twit.rar
(3.46 KiB) Downloaded 45 times

Post Reply