1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Follow twitter user raw HTTP (Help)

Discussion in 'Twitter' started by Kollongder1, May 3, 2015.

  1. Kollongder1

    Kollongder1 Newbie

    Joined:
    May 3, 2015
    Messages:
    3
    Likes Received:
    0
    Hello,

    I am currently developing a bot to be able to follow users using raw HTTP and with to have no contact with the twitter API whatsoever.

    I have managed to login with an account, but now, I am wondering, how do you follow another user on Twitter using raw HTTP? I have viewed and checked the HTML/JS for the twitter page but can not find anything.

    I see that many have created bots for twitter here, so can anyone help me?

    The one that can help me with this, I am prepared to give you a little payment as a thanks.

    Regards,
     
  2. Standard Toaster

    Standard Toaster Regular Member

    Joined:
    Aug 29, 2009
    Messages:
    336
    Likes Received:
    190
    You have to simulate the POST requests that twitter web performs. To check the requests being sent, you can use Network Monitor in chrome console or something like Fiddler. I think these are enough hints to get you started. Google around and you'll find your way.

    If you have any specific questions, feel free to PM me.

    Good Luck
     
  3. Repulsor

    Repulsor Power Member

    Joined:
    Jun 11, 2013
    Messages:
    766
    Likes Received:
    275
    Location:
    PHP Scripting ;)
    Or you can use Live HTTP Headers addon for firefox to identify the requests, the fields being sent and all sort. Then you have to make a post to the said url with all the fields.

    Live HTTP headers is real good one.
     
  4. Kollongder1

    Kollongder1 Newbie

    Joined:
    May 3, 2015
    Messages:
    3
    Likes Received:
    0
    Yes, but the thing is, when you login to twitter and click on "follow" for someone, the click triggers somekind of POST in the background, so it is hard to really "track" it.

    Its easier when you want to simulate the login process because there you can simply copy the POST form for the login on the twitter page and send a typical POST.

    But not the same applies for the FollowButton.

    Any detailed insights on this?
     
  5. Kollongder1

    Kollongder1 Newbie

    Joined:
    May 3, 2015
    Messages:
    3
    Likes Received:
    0
    I cant PM you, I do not have 15 Points :/ have you done something similar?
     
  6. jamie3000

    jamie3000 Supreme Member

    Joined:
    Jun 30, 2014
    Messages:
    1,305
    Likes Received:
    586
    Occupation:
    Finance coder looking for semi-retirement
    Location:
    uk
    GRAB THE USERS

    $header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36';
    $c = curl_init('https://twitter.com/'.$user_to_scrape.'/followers/users?cursor='.$data_cursor_value.'&cursor_index=&cursor_offset=&include_available_features=1&include_entities=1&is_forward=true');
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
    curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($c, CURLOPT_HTTPHEADER, $header);
    curl_setopt($c, CURLOPT_CONNECTTIMEOUT , 60);
    curl_setopt($c, CURLOPT_TIMEOUT, 60);
    curl_setopt($c ,CURLOPT_ENCODING, "gzip");
    $follow_ajax_responce = curl_exec($c);

    SEND THE FOLLOW REQUEST
    $url = 'https://twitter.com/i/user/follow';


    $fields = array(
    'authenticity_token' => urlencode($auth_value),
    'challenges_passed' => urlencode('false'),
    'handles_challenges' => urlencode('1'),
    'impression_id' => urlencode(''),
    'inject_tweet' => urlencode('false'),
    'user_id' => urlencode($user_id),
    );


    //url-ify the data for the POST
    $fields_string = '';
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string, '&');


    //open connection
    $c = curl_init();


    $header = array();
    $header[] = 'Origin: https://twitter.com';
    $header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36';
    $header[] = 'Content-Type: application/x-www-form-urlencoded';
    $header[] = 'X-Requested-With: XMLHttpRequest';
    $header[] = 'Referer: https://twitter.com/'.$user_name.'/followers';


    //set the url, number of POST vars, POST data
    curl_setopt($c, CURLOPT_URL, $url);
    curl_setopt($c, CURLOPT_POST, count($fields));
    curl_setopt($c, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);
    curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);
    curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($c, CURLOPT_HTTPHEADER, $header);
    curl_setopt($c, CURLOPT_CONNECTTIMEOUT ,60);
    curl_setopt($c, CURLOPT_TIMEOUT, 60);
    curl_setopt($c ,CURLOPT_ENCODING, "gzip");
    $follow_ajax_responce = curl_exec($c);

    //execute post
    $result_of_follow = curl_exec($c);
     
  7. phatzilla

    phatzilla Jr. VIP Jr. VIP

    Joined:
    Apr 9, 2009
    Messages:
    1,383
    Likes Received:
    1,023

    All you need is a web debugging proxy like fiddler/charles/burp.