curl php总是得到错误403

时间:2017-02-27 22:26:01

标签: php curl

你好我试图使用curl获取页面但总是收到错误403.有没有办法获得这个网页?

我的源代码是这样的

<?php
set_time_limit(0);
error_reporting(0);
$LOGINURL = "https://sso.orange.fr/espace-client/desimlockage";
$ch = curl_init();
$headers[] = "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
$headers[] = "Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4";
$headers[] = "Connection: Keep-Alive";
$headers[] = "Host:iz.orange.fr";
$headers[] = "Referer:http://www.sosh.fr/espace-client-accueil";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: curl/7.39.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $LOGINURL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$content = curl_exec($ch);
echo $content;
?>

1 个答案:

答案 0 :(得分:0)

评论curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,1);并尝试一次。希望它能帮到你。