Curl facebook cookie problem

0

I'm trying to get into facebook by pho using curl but I'm having the problem:

  

Cookies required Cookies are not enabled in your browser.   Please enable cookies in your browser preferences to continue.

Pieceofcode:

curl_setopt($ch,CURLOPT_URL,"https://www.facebook.com/login.php?login_attempt=1&lwv=111");
            // gera cookie
            curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd().'/Cookies/'.$random.'.txt');
            // levar cookie
            curl_setopt($ch, CURLOPT_COOKIEFILE, '/Cookies/'.$random.'.txt');
            // diz que nao vai verificar o peer (https)
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            //
            curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
            // diz que nao vai verificar o host (https)
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            // cabeçalho do site
            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: www.facebook.com", "Connection: keep-alive", ""));
            // navegador que foi feito o request
            curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
            // diz que vai mostrar o resultado
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            // diz que vai seguir os codigos redirect
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            // executa o curl
            // $data = curl_exec($ch);
            // diz que vai fazer post
            curl_setopt($ch, CURLOPT_POST, 1);
            // informa as informacoes para serem dadas
            curl_setopt($ch, CURLOPT_POSTFIELDS, "exemplo...");

            $this->data = curl_exec($ch);

How can I resolve?

Obs: error solved, I placed a curl_exec before the post and stopped. Can someone explain to me why?

    
asked by anonymous 04.04.2018 / 22:55

0 answers