Answer the question
In order to leave comments, you need to log in
PHP cUrl: Why am I getting a 403 error?
Hello. I'm trying to send a cUrl request from php to reddit. I would like to delete comments by sending a request from the server, to do this, I first deleted the comment manually, and then looked at what was sent to the server
. I tried to use the Replay XHR function in the browser and the request gave the code 200
. code 200.
After that, I copied the information exactly into my cUrl request
// Массив POST
$post = array(
'id' => 't1_id комментария'
);
// Массив заголовков, как в браузере
$header = array(
'authority' => 'oauth.reddit.com',
'accept' => '*/*',
'accept-encoding' => 'gzip, deflate, br',
'accept-language' => 'en-GB,en;q=0.9',
'authorization' => 'скопировал в точности',
'content-length' => 13,
'content-type' => 'application/x-www-form-urlencoded',
'origin' => 'https://www.reddit.com',
'referer' => 'https://www.reddit.com/',
'sec-ch-ua' => '^\\^Chromium^\\^;v=^\\^90^\\^, ^\\^Opera^\\^;v=^\\^76^\\^, ^\\^;Not',
'sec-ch-ua-mobile' => '?0',
'sec-fetch-dest' => 'empty',
'sec-fetch-mode' => 'cors',
'sec-fetch-site' => 'same-site',
'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 OPR/76.0.4017.177',
'x-reddit-loid' => 'скопировал в точности',
'x-reddit-session' => 'скопировал в точности'
);
// Параметры cUrl запросу я задал такие
curl_setopt(${"chan".$i}, CURLOPT_RETURNTRANSFER, true);
curl_setopt(${"chan".$i}, CURLOPT_HEADER, true);
curl_setopt(${"chan".$i}, CURLOPT_HTTPHEADER, $header);
curl_setopt(${"chan".$i}, CURLOPT_POST, true);
curl_setopt(${"chan".$i}, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt(${"chan".$i}, CURLOPT_AUTOREFERER, true);
curl_setopt(${"chan".$i}, CURLOPT_TIMEOUT, 30);
curl_setopt(${"chan".$i}, CURLOPT_FOLLOWLOCATION,true);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question