0
I have the following code:
$url = 'https://twitter.com/' . $username;
$user = curl_init();
curl_setopt_array($user, [
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CAINFO => 'cacert-2017-06-07.pem',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_HTTPHEADER => [
"Content-type:text/html;charset=utf-8",
],
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 2,
CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
CURLOPT_POSTREDIR => 2,
CURLOPT_AUTOREFERER => 1,
CURLOPT_ENCODING => "gzip"
]
);
$user_info = json_encode(curl_exec($user));
//$user_info = json_decode(curl_exec($user));
var_dump($user_info);
echo $user_info;
Well, it returns to me:
I would like to extract information such as:
Screen_name, Name, Profile_img, etc
A friend of a site owner said it is possible, but he did not want to give his arm to twist and teach me, what is the logic behind? It is possible?
Monitoring the network
got this:
-H "accept-encoding: gzip, deflate, br"
-H "accept-language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4"
-H "upgrade-insecure-requests: 1"
-H "user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
-H "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
-H "cache-control: max-age=0"
-H "authority: twitter.com"
I’ve done everything I’m doing since yesterday trying to debug it, and I don’t understand this part "Any particular reason not to use Curl?"
– user76271
I read the wrong title. My mistake. I had read "Get information without Curl". Sorry.
– Woss
At a glance: https://answall.com/a/218866/3635
– Guilherme Nascimento
Oops, here’s settled, but I’ll read.
– user76271
@Guilhermenascimento, I will open a question, about Curl and token can help me?
– user76271