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

    Nov 2, 2009
    Likes Received:
    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:


    //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: 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/';
    $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);



    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

    Aug 19, 2011
    Likes Received:
    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