Public Member Functions | Static Public Member Functions | Protected Attributes

ilCurlConnection Class Reference

Public Member Functions

 __construct ($a_url= '')
 Constructor.
 init ()
 Init curl connection.
 setOpt ($a_option, $a_value)
 Wrapper for curl_setopt.
 exec ()
 Wrapper for curl_exec.
 close ()
 Close connection.
 __destruct ()
 Destructor.

Static Public Member Functions

static _isCurlExtensionLoaded ()
 Check if curl extension is loaded.

Protected Attributes

 $url = ''
 $ch = null

Detailed Description

Definition at line 38 of file class.ilCurlConnection.php.


Constructor & Destructor Documentation

ilCurlConnection::__construct ( a_url = ''  ) 

Constructor.

public

Parameters:
string url for connection
Exceptions:
ilCurlConnectionException 

Definition at line 51 of file class.ilCurlConnection.php.

        {
                $this->url = $a_url;
                
                if(!self::_isCurlExtensionLoaded())
                {
                        throw new ilCurlConnectionException('Curl extension not enabled.');
                }
        }

ilCurlConnection::__destruct (  ) 

Destructor.

public

Parameters:
 

Definition at line 168 of file class.ilCurlConnection.php.

References close().

        {
                $this->close();
        }

Here is the call graph for this function:


Member Function Documentation

static ilCurlConnection::_isCurlExtensionLoaded (  )  [static, final]

Check if curl extension is loaded.

public

Definition at line 68 of file class.ilCurlConnection.php.

        {
                if(!function_exists('curl_init'))
                {
                        return false;
                }
                return true;
        }

ilCurlConnection::close (  )  [final]

Close connection.

public

Definition at line 153 of file class.ilCurlConnection.php.

Referenced by __destruct().

        {
                if($this->ch != null)
                {
                        curl_close($this->ch);
                }
        }

Here is the caller graph for this function:

ilCurlConnection::exec (  )  [final]

Wrapper for curl_exec.

public

Parameters:
 

Definition at line 131 of file class.ilCurlConnection.php.

References $res.

        {
                if((@$res = curl_exec($this->ch)) === false)
                {
                        if(strlen($err = curl_error($this->ch)))
                        {
                                throw new ilCurlConnectionException($err,curl_errno($this->ch));
                        }
                        else
                        {
                                throw new ilCurlConnectionException('Error calling curl_exec().');
                        }
                }
                return $res;
        }

ilCurlConnection::init (  )  [final]

Init curl connection.

public

Exceptions:
ilCurlConnectionException on error

Definition at line 84 of file class.ilCurlConnection.php.

        {
                if(strlen($this->url))
                {
                        $this->ch = curl_init($this->url);
                }
                else
                {
                        $this->ch = curl_init();
                }
                if(!$this->ch)
                {
                        throw new ilCurlConnectionException('Cannot init curl connection.');
                }
                if(curl_errno($this->ch))
                {
                        throw new ilCurlConnectionException(curl_error($this->ch),curl_errno($this->ch));
                }
                
                return true;
        }

ilCurlConnection::setOpt ( a_option,
a_value 
) [final]

Wrapper for curl_setopt.

public

Parameters:
int CURL_OPTION
mixed bool string or resource
Exceptions:
ilCurlConnectionException on error

Definition at line 115 of file class.ilCurlConnection.php.

        {
                if(!@curl_setopt($this->ch,$a_option,$a_value))
                {
                        throw new ilCurlConnectionException('Invalid option given for: '.$a_option,curl_errno($this->ch));
                }
                return true;
        }


Field Documentation

ilCurlConnection::$ch = null [protected]

Definition at line 41 of file class.ilCurlConnection.php.

ilCurlConnection::$url = '' [protected]

Definition at line 40 of file class.ilCurlConnection.php.


The documentation for this class was generated from the following file: