0
다른 서버에서 호스팅되는 Laravel 컨트롤러 메서드에서 전달 된 json 파일을 인쇄해야합니다. laravel 컨트롤러에서 Json 파일 가져 오기
echo '<pre>'.print_r(json_decode(file_get_contents("http://xxx.xxx.xx.xx/myproject/public/send")),1).'</pre>';
그리고 내 web.php 파일
내가Route::get('/send', 'Test\[email protected]');
I가, 수신기 PHP 파일 (기본 PHP)에서
function curlrequest($url, $data){
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($handle);
if($output === FALSE) {
die(curl_error($handle));
}else{
return $output;
}
curl_close($handle);
}
, 내가 다음 코드 한 다음과 같은 코드를 보내기 아직이 코드를 실행하지 않았습니다. 하지만 file_get_content 메소드를 사용하여 경로에 액세스 할 수 없다는 것을 알았습니다. 누구든지이 상황에서 json을 전달할 적절한 방법이 무엇인지 말해 줄 수 있습니까?