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:
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
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 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/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: