Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP CURL - Empty output with no error [closed]

Tags:

php

curl

I am not getting the curl output for valid url, sample $url= http://linkedin.com/pub/4/b29/8a0

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,           "$url");
curl_setopt($ch, CURLOPT_TIMEOUT,       60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

$referer = WebCrawl::getRandomURL();
curl_setopt($ch, CURLOPT_REFERER,       $referer);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_COOKIEJAR,     "cookie.txt");

curl_setopt($ch, CURLOPT_USERAGENT,     "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");

$body = curl_exec($ch);
$error_no = curl_errno($ch);
like image 505
Muzaffer Avatar asked Nov 06 '12 12:11

Muzaffer


1 Answers

function getURL($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        $tmp = curl_exec($ch);
        curl_close($ch);
        if ($tmp != false){
            return $tmp;
        }
    }
like image 183
heart_hacker Avatar answered Oct 28 '22 01:10

heart_hacker