OBS: THE COMPLETE CODE IS HERE , but I made this adjustment to receive cookies
I'm trying to read the cookie files to make the requisite requests to get the result I expect, see my code:
$tokens = ['_twitter_sess', 'ct0', 'auth_token'];
foreach (glob($this->_cookieFile) as $file) {
$pointer = fopen($file, 'r');
while (!feof($pointer)) {
$line = fgets($pointer);
foreach ($tokens as $token) {
if (stripos($line, $token) !== false) {
var_dump($line);
curl_setopt_array($request, [
CURLOPT_COOKIEFILE => $line,
CURLOPT_HTTPHEADER => [
'origin: https://twitter.com',
'authorization: Bearer ' . $bearer,
'x-csrf-token: ' . $line,
'referer: https://twitter.com/',
'x-twitter-auth-type: OAuth2Session',
'x-twitter-active-user: yes',
],
CURLOPT_POSTFIELDS => http_build_query([
'challenges_passed' => false,
'handles_challenges' => 1,
'include_blocked_by' => true,
'include_blocking' => true,
'include_can_dm' => true,
'include_followed_by' => true,
'include_mute_edge' => true,
'skip_status' => true,
'user_id' => Session::get('username'),
], '', '&', PHP_QUERY_RFC3986),
]
);
break;
}
}
}
}
But giving var_dump
to $line
, I get a return:
Ineedtoreadeachlineinaarrayassociativo
orreadallcookiesatonce.
SohowdoIreturnmycURL
returnsme:
'{"errors":[{"code":220,"message":"Your credentials do not allow access to this resource."}]}' (length=92)