CURL for Yii
...requirements of using this extension (e.g. Yii 1.1 or above)... ..You must have CURL enabled in order to use this extension...
BASIC IMPLEMENTATION
'CURL' =>array( 'class' => 'application.extensions.curl.Curl', )
ADVANCED IMPLEMENTATION
'curl' => array( 'class' => 'application.extensions.curl.Curl', 'options'=>array( 'timeout'=>0, 'cookie'=>array( 'set'=>'cookie' ), 'login'=>array( 'username'=>'myuser', 'password'=>'mypass' ), 'proxy'=>array( 'url'=>'someproxy.com', 'port'=>80 ), 'proxylogin'=>array( 'username'=>'someuser', 'password'=>'somepasswords' ), 'setOptions'=>array( CURLOPT_UPLOAD => true, CURLOPT_USERAGENT => Yii::app()->params['agent'] ), ) ),
GET EXAMPLES
$run_one = Yii::app()->curl->run('http://maps.google.com/maps/geo?q=zagreb&output=json&key=ABQIAAAAR3YzPp1SL-w7k-Nhadw6oRRSU9EEwCG8ydw3m56rm2GtI8BohRSHN1qNuRyOrnYS_BNY1_2RnyuYTA'); if(!$run_one->hasErrors()) { echo '<pre>'; print_r(json_decode($run_one->getData())); echo '</pre>'; echo $run_one->getInfo(); } else { echo '<pre>'; var_dump($run_one->getErrors()); echo '</pre>'; } $run_two = Yii::app()->curl->run('http://www.google.com/ig/calculator?q=100EUR=?HRK'); if(!$run_two->hasErrors()) { echo '<pre>'; print_r(json_decode($run_two->getData())); echo '</pre>'; echo $run_two->getInfo(); } else { echo '<pre>'; var_dump($run_two->getErrors()); echo '</pre>'; }
Total 12 comments
Demo please...
hi, how to add .cert and .key files to connection?
Thanks a lot
There is missing a 'N' on line 179 at "CURLOPT_FOLLOWLOCATIO".
Good extension though!
I receive an error
There is the fix of same issue for osCommerce, it can be useful for you.
It would probably be wiser to use a string or constant for the request type. I cannot help it but I hate booleans parameters and if you've worked with payment gateway integration you know why. :) Good job with the extension, nevertheless.
If you set to false your request become POST request.
What is the purposue of the boolean GET parameter, in the run function header?
Thank you...great job!
useful! thx!
I was just about to write one for this :) Thakns!
Nice extension, useful too...
Leave a comment
Please login to leave your comment.