curl You can use it for geting data from other websites via CURL

  1. Requirements
  2. Usage

CURL for Yii

Requirements ¶

...requirements of using this extension (e.g. Yii 1.1 or above)... ..You must have CURL enabled in order to use this extension...

Usage ¶

  1. You have to download and upload files to /protected/extensions/curl/.
  2. Include extension in config/main.php

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>';
}
34 2
43 followers
6 227 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Web Service
Developed by: Igor Ivanovic Igor Ivanovic
Created on: Dec 16, 2010
Last updated: 12 years ago

Downloads

show all

Related Extensions