0
I’m studying cURL
to continue in my applying, I reviewed my code and monitored the network from Twitter and got the following HTTP Headers
:
curl "https://twitter.com/"
-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"
-H "cookie: (RETIRADO POR SEGURANÇA!) --compressed
My code is very simple, but the doubt has arisen, there is need to make the same calls?
Beneath my simple code:
$cookies = [];
$url_twitter = 'https://twitter.com';
$twitter_cookies = curl_init();
curl_setopt_array($twitter_cookies, [
CURLOPT_URL => $url_twitter,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_COOKIEJAR => ROOT . 'system' . SEPARATOR . 'cookies' . SEPARATOR . $TwitterUser . '.txt',
CURLOPT_HEADERFUNCTION => function($twitter_cookies, $header) use (&$cookies) {
if (stripos($header, 'Set-Cookie:') === 0) {
if (preg_match('/Set-Cookie:\s?(.*?);/i', $header, $matches)) {
$cookies[] = $matches[1];
}
}
return strlen($header);
}
]
);
As you can see I haven’t implemented even half of the HEADERS that Twitter showed when copying cURL
quoted at the beginning of the topic.
I don’t know if it adds automatically, I understand the basics of HTTPS
, but there is need to make these calls or it is added automatically?
"accept-encoding: gzip, deflate, br"
"accept-language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4"
"upgrade-insecure-requests: 1"
"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"
"accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
"cache-control: max-age=0"
Paul, I don’t know if it’s the answer or if it’s me, but I don’t understand. (?) Forgiveness.
– user76271
It is necessary to study the system that will receive the request to know if it is necessary to inform all the parameters or not.
– Paulo Martins
Yes, forgive my ignorance, but what are these studies?
– user76271
You’re gonna send a post to some Twitter endpoint right? Then you will need to search the twitter documentation for any way to accomplish this integration with your system. Have a look at: https://dev.twitter.com/
– Paulo Martins
Yes, I will send without using API. I will mark your reply as solved. thanks.
– user76271
Well, in this case there is not much to discover the necessary fields :/, var have to be in the kick.
– Paulo Martins