linslin/Yii2-Curl

curl_getinfo

tobciu opened this issue · 5 comments

please provide the informations as an associative array from curl_getinfo

see: http://php.net/manual/de/function.curl-getinfo.php
-> 'If opt is given, returns its value. Otherwise, returns an associative array with the following elements (which correspond to opt)'

i need 'CURLINFO_REDIRECT_COUNT' for better parsing the response ;-)

Hey @tobciu , good one. This will be added!

Well, here you are. I released Version 1.0.6. https://packagist.org/packages/linslin/yii2-curl

        //init curl
        $curl = new curl\Curl();

        //get http://example.com/
        $response = $curl
            ->setOption(CURLOPT_CONNECTTIMEOUT, 5)
            ->setOption(CURLOPT_RETURNTRANSFER, true)
            ->get('http://www.linslin.org/');


        var_dump($curl->getInfo()); //return all infos as array
        var_dump($curl->getInfo(CURLINFO_REDIRECT_COUNT)); // return info by OPT

in Line

} elseif ($opt !== null) {
you can get a null-pointer exception if you call the 'reset' method before you call the 'getInfo' method

Thanks, is fixed in 1.0.7. Cheers.

thank you for your fast response 👍 :-)