Salut,
Nu stiu care sa fie problema; totusi, incearca unul din aceste coduri:
- Cu metoda cURL
Cod: Selectaţi tot
<?php
header('Content-type: text/html; charset=utf-8');
function get_web_page($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_REFERER, '');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml\r\n'.
'Authorization: Bearer sdf541gs6df51gsd1bsb16etb16teg1etr1ge61g\n'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_VERBOSE , 1);
$response = curl_exec($ch);
if(curl_errno($ch) !== CURLE_OK){
throw new \RuntimeException('curl_exec error: '. curl_error($ch) .': '. curl_error($ch));
}
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
curl_close($ch);
return array('header'=>$header, 'body'=>$body);
}
$url ='https://marplo.net/';
$get_pg = get_web_page($url);
echo $get_pg['header'];
echo $get_pg['body'];
- Cu file_get_contents():
Cod: Selectaţi tot
<?php
header('Content-type: text/html; charset=utf-8');
$url ='https://marplo.net/';
$opts = array('http' => array(
'method' =>'GET',
'http' => array('ignore_errors'),
'header' =>
'Content-Type: application/x-www-form-urlencoded\r\n'.
'Authorization: Bearer sdf541gs6df51gsd1bsb16etb16teg1etr1ge61g\n',
'content' => $url
));
$context = stream_context_create($opts);
$res = file_get_contents($url, false, $context);
echo $res;