Я пытаюсь отправить запрос на первый сервер с помощью GuzzleHttp на второй сервер
http://imei.sy/imei
Которые имеют csrf_field ()
ошибки:
500 Внутренняя ошибка
так как публиковать с csrf_filed
Я делаю тот же сервер (локально)
когда я остановил csrf на первом успешном посте сервера
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use function GuzzleHttp\Promise\each;
use GuzzleHttp\Client as GuzzleClient;
class Guz extends Controller
{
//
//public $url = "http://127.0.0.1:8001/add";
public $url = "http://imei.sy/imei";
// Make Get request , re
public function getGuzzleRequest()
{
$client = new \GuzzleHttp\Client();
$request = $client->get($this->url);
$response = $request->getBody();
// dd( (string) $response);
return $this->get_string_between( (string) $response,"token\" content=\"","\">");
}
public function postGuzzleRequest()
{
$client = new \GuzzleHttp\Client();
$body = [
'imei' => '99999',
//'price' => 333,
'_token'=> $this->getGuzzleRequest()
];
$r = $client->request('POST', $this->url, [
'form_params' => $body
]);
$response = $r->getBody()->getContents();
dd($response);
}
private function get_string_between($string, $start, $end){ // Get
if($start != ''){
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0) return '';
$ini += strlen($start);
}
else{
$ini = 0;
}
if ($end == '') {
return substr($string, $ini);
}
else{
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
}
}
Route::get('/guzg',"Guz@getGuzzleRequest");
Route::get('/guzp',"Guz@postGuzzleRequest");
ошибки:
419 неизвестный статус` ответ