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

PINTEREST, Make an automic inlog script using PHP and CURL

Discussion in 'Social Networking Sites' started by joetje, Nov 6, 2013.

  1. joetje

    joetje Newbie

    Joined:
    Nov 2, 2009
    Messages:
    9
    Likes Received:
    5
    Hi All,

    I hope this is posten in the correct section of the board.

    Long story short, I am trying to make a script with PHP using Curl to login to pinterest. I know there have been scripts like this before, but due to changes in pinterest these don't work anymore. Perhaps if we work together we can make this thing work and help us autopost to pinterest.

    I made a start with login, however, I get the pinterest 'oops, something went wrong' message.

    This is my code so far:

    PHP:
    <?php

    //This is how we authenicate to Pinterest
    function login() {        // Create Cookie File        $cookiefile = '';        if (file_exists($cookiefile)) { unlink ($cookiefile); }        //User and pass to Pinterest        $username = "username!!!";        $password = "password!!!!";
            // initial login page which redirects to correct sign in page, sets some cookies
            
    $URL =  '****s : \\***pinterest***\login\';        $ch  = curl_init();        curl_setopt($ch, CURLOPT_URL, $URL);        //curl_setopt($ch, CURLOPT_SESSIONCOOKIE, True);        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11ULinux x86_64en-USrv:1.9.2.13Gecko/20101206 Ubuntu/10.10 (maverickFirefox/3.6.13');              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);        curl_setopt($ch, CURLOPT_HEADER, 1);               curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);        curl_setopt($ch, CURLOPT_VERBOSE, true);            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);                $page = curl_exec($ch);              

    $app_version = substr($page,strpos($page,'
    {"app_version""') + 17,7);
     
    $file = file_get_contents($cookiefile);$token = substr($file,strpos($file,'csrftoken')+10,32);




    $data= 'source_url=/login/&data={"options":{"username_or_email":"'.$username.'","password":"'.$password.'","context":{"app_version":"'.$app_version.'"}}&module_path=App()>LoginPage()>Login()>Button(class_name=primary, text=Log in, type=submit, tagName=button, size = large)';$data = urlencode($data);


    $URL2 = '****s***pinterest***\resource\UserSessionResource\create/';
    curl_setopt(
    $ch, CURLOPT_URL, $URL2);curl_setopt($ch, CURLOPT_REFERER, $URL);curl_setopt($ch, CURLOPT_POSTFIELDS,$data); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIE, $token);  curl_setopt($ch, CURLOPT_VERBOSE, true);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);$page = curl_exec($ch);
    echo 
    $page;          



            
            
            


    }

    ?>
    I am sure I am not the only one interested in such a script. Perhaps some of us can work together and fix this piece of code. Cheers

    ps Unfortunately I am not yet allowed to post urls, so please correct them in the script if you try to run it ;)!

    pps Unfortunately the script got messed up while posting here, don't know how to fix it :X
     
    Last edited: Nov 6, 2013
  2. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,288
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
    install yourself a web debugging tools like Charles or Fiddler and with it inspect the exact variables sent to the login by using your browser and then adjust your php code to use the same... that should probably help
     
    • Thanks Thanks x 1