ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCurlConnection Class Reference
+ Collaboration diagram for ilCurlConnection:

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.
 getInfo ($opt=0)
 Get informations about a specific transfer.
 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
stringurl 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 189 of file class.ilCurlConnection.php.

References close().

{
$this->close();
}

+ Here is the call graph for this function:

Member Function Documentation

static ilCurlConnection::_isCurlExtensionLoaded ( )
staticfinal

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 174 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::getInfo (   $opt = 0)

Get informations about a specific transfer.

public

Parameters
intoption e.g CURLINFO_EFFECTIVE_URL
Returns
mixed

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

References $res.

{
if($opt)
{
$res = curl_getinfo($this->ch,$opt);
}
else
{
$res = curl_getinfo($this->ch);
}
return $res;
}
ilCurlConnection::init ( )
final

Init curl connection.

public

Exceptions
ilCurlConnectionExceptionon error

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

Referenced by ilECSConnector\prepareConnection().

{
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;
}

+ Here is the caller graph for this function:

ilCurlConnection::setOpt (   $a_option,
  $a_value 
)
final

Wrapper for curl_setopt.

public

Parameters
intCURL_OPTION
mixedbool string or resource
Exceptions
ilCurlConnectionExceptionon 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: