I am trying to login to twitter with php + curl, but I think that something is wrong with my request, because I get this as an answer:
Something is technically wrong.
Thank you for noticing - we are going to fix it and return it normally.
The PHP code I'm using is:
<?php $ch = curl_init($sTarget); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIEJAR, $_CKS); curl_setopt($ch, CURLOPT_COOKIEFILE, $_CKS); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data")); curl_setopt($ch, CURLOPT_REFERER, "https://twitter.com"); ?>
$ sPost is as follows:
Session [username_or_email] = user & session [password] = password & Remember_Me = 1 & scribe_log = & redirect_after_login = & authenticity_token = 6e706165609354bd7a92a99cf94e09140ea86c6f
First, the code retrieves the fields of the login form so that the message variables have the correct values (authentication token). I just tried everything, and yes, I know there is an api for this, but I’ll better learn how to do it manually for training.
Thanks in advance.