$CURL = CURL::init();
$url = 'https://mbasic.facebook.com/';
$loginPage = $CURL->request($url);
preg_match_all('/name=\"lsd\" value=\"(.*?)\".*name=\"m_ts\" value=\"(.*?)\".*name=\"li\" value=\"(.*?)\"/mi', $loginPage, $matches);
if(isset($matches[1][0])) {
$url = "https://mbasic.facebook.com/login.php?refsrc=https%3A%2F%2Fmbasic.facebook.com%2F&lwv=100&login_try_number=1&refid=8";
$query = 'lsd={{LSD}}&version=1&ajax=0&width=0&pxr=0&gps=0&dimensions=0&m_ts={{M_TS}}&li={{LI}}&email={{EMAIL}}&pass={{PASS}}&login=%D0%92%D1%85%D0%BE%D0%B4';
$query = str_replace('{{LSD}}', $matches[1][0], $query);
$query = str_replace('{{M_TS}}', $matches[2][0], $query);
$query = str_replace('{{LI}}', $matches[3][0], $query);
//$query = str_replace('{{EMAIL}}', "neutralbyte@mail.ru", $query);
//$query = str_replace('{{PASS}}', "123456789123456789", $query);
$query = str_replace('{{EMAIL}}', "{тут email для авторизации}", $query);
$query = str_replace('{{PASS}}', "{пароль}", $query);
$data = $CURL->request($url, $query, true);
class CURL {
static private $_instance;
private $resource;
private $socket;
//Singleton
private function __construct() {
$this->reinit();
}
private function __clone(){}
public static function init() {
if(self::$_instance == null) {
self::$_instance = new CURL();
}
return self::$_instance;
}
private function reinit() {
$this->resource = curl_init();
curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->resource, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($this->resource, CURLOPT_COOKIEJAR, "cookies.txt");
//curl_setopt($this->resource, CURLOPT_HEADER, 1);
curl_setopt($this->resource, CURLOPT_FOLLOWLOCATION, 1);
}
public function get_info() {
return curl_getinfo($this->resource);
}
public function request($url, $query='', $isPOST=false, $headers = null) {
if(!$this->resource) {
$this->reinit();
}
//curl_setopt($this->resource, CURLOPT_USERAGENT, "Mozilla/5.0 (бла бла бла..) ");
if($headers == null) {
$headers = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*;q=0.8',
'Accept-Language: ru,en-us;q=0.7,en;q=0.3',
'Accept-Encoding: deflate',
'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7',
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0'
);
}
curl_setopt($this->resource, CURLOPT_HTTPHEADER, $headers);
curl_setopt($this->resource, CURLOPT_URL, $url);
curl_setopt($this->resource, CURLOPT_POST, $isPOST);
if($isPOST) {
curl_setopt($this->resource, CURLOPT_POSTFIELDS, $query);
}
return curl_exec($this->resource);
}
public function download($url) {
if(!$this->resource) {
$this->reinit();
}
curl_setopt($this->resource, CURLOPT_URL, $url);
return curl_exec($this->resource);
}
public function send($url, $query) {
$uri = parse_url($url);
$host = $uri['host'];
$path = $uri['path'];
$this->socket = fsockopen($host, 80, $e1, $e2, 10);
socket_set_blocking($this->socket, false);
$headers = "POST ".$path." HTTP/1.1\r\n";
$headers .= "Host: ".$host."\r\n";
$headers .= "Connection: Close\r\n";
if(empty($query)) {
$headers .= "\r\n";
}
else {
$headers .= "Content-Type: application/x-www-form-urlencoded\r\n";
$headers .= "Content-Length: ".strlen($query)."\r\n\r\n";
$headers .= $query;
}
fputs($this->socket, $headers);
}
public function close() {
if($this->resource) {
curl_close($this->resource);
}
if($this->socket) {
fclose($this->socket);
}
}
}
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\App\Http\Middleware\Maintenance::class,
],
надо регистрировать в группе web
Чтобы каждый раз не дергать, можно материал кешировать вместе со всеми полями.