0
I’m trying the following return on my code PHP
, that even with these topics helped me a lot: First, According to
C: wamp64 www test index.php:61:string 'HTTP/1.1 302 Found cache-control: no-cache, max-age=300 content-length: 157 content-security-policy: default-src 'None'; connect-src 'self'; font-src https://abs.twimg.com https://abs-0.twimg.com data:; frame-src'self 'twitter:; frame-ancestors'self' https://tweetdeck.twitter.com https://tdapi-staging.smf1.twitter.com https://tdapi-staging.atla.twitter.com https://tweetdeck.localhost.twitter.com; img-src https://abs.twimg.com https:/*.twimg.com https://pbs.twimg.com date:; media-src 'None'; Object-src'... (length=116072)
My PHP code:
<?php
$cookie = [];
$index_url = 'https://twitter.com';
$token = curl_init();
curl_setopt_array($token, [
CURLOPT_URL => $index_url,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_REFERER => $index_url,
CURLOPT_HEADER => TRUE,
CURLOPT_HEADERFUNCTION => function($curl, $header) use (&$cookie){
if(stripos($header, 'Set-Cookie:') === 0){
if(preg_match('/Set-Cookie:\s?(.*?);/i', $header, $matches)) {
// $cookie .= $matches[1] . '; ';
$cookie[] = $matches[1];
}
}
//var_dump($header);
return strlen($header);
}
]
);
$access = curl_exec($token);
preg_match('/value="(.*?)" name="authenticity_token"/', $access, $matches);
$authenticity_token = $matches[1];
//how to use cookie array
//$cookie[0];
$username = 'jhonesstevan';
$password = 'laranjao1020';
$session_post = "session[username_or_email]=$username&session[password]=$password&return_to_ssl=true&scribe_log=&redirect_after_login=%2F&authenticity_token=$authenticity_token";
$session_url = 'https://twitter.com/sessions';
curl_setopt_array($token, [
CURLOPT_URL => $session_url,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $session_post,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Content-type: application/x-www-form-urlencoded"
],
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_HEADER => TRUE,
CURLOPT_FOLLOWLOCATION => 1,
]
);
$auth = curl_exec($token);
var_dump($auth);
PS: Account fake.
– user76271