PHPCap Docs | PHPCap API
Overview

Namespaces

  • IU
    • PHPCap
  • PHP

Classes

  • ErrorHandler
  • FileUtil
  • RedCap
  • RedCapApiConnection
  • RedCapProject

Interfaces

  • ErrorHandlerInterface
  • RedCapApiConnectionInterface

Exceptions

  • PhpCapException
  • Overview
  • Namespace
  • Class

Class RedCapApiConnection

A connection to the API of a REDCap instance. This class provides a low-level interface to the REDCap API, and is primarily intended for internal use by PHPCap, but could be used directly by a user to access REDCap functionality not provided by PHPCap.

IU\PHPCap\RedCapApiConnection implements IU\PHPCap\RedCapApiConnectionInterface
Namespace: IU\PHPCap
Located at RedCapApiConnection.php
Methods summary
public
+/- __construct( string $url, boolean $sslVerify = false, string $caCertificateFile = '', IU\PHPCap\ErrorHandlerInterface $errorHandler = null )

Constructor that creates a REDCap API connection for the specified URL, with the specified settings.

Constructor that creates a REDCap API connection for the specified URL, with the specified settings.

Parameters

$url
the URL for the API of the REDCap site that you want to connect to.
$sslVerify

indicates if verification should be done for the SSL connection to REDCap. Setting this to false is not secure.

$caCertificateFile

the CA (Certificate Authority) certificate file used for veriying the REDCap site's SSL certificate (i.e., for verifying that the REDCap site that is connected to is the one specified).

$errorHandler
the error handler for the connection.

Throws

IU\PHPCap\PhpCapException
if an error occurs and the default error handler is being used.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::__construct()
public
+/- __destruct( )

Closes the cURL handle (if it is set).

Closes the cURL handle (if it is set).

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::__destruct()
public string
+/- call( mixed $data )

Makes a call to REDCap's API and returns the results.

Makes a call to REDCap's API and returns the results.

Parameters

$data
data for the call.

Returns

string

the response returned by the REDCap API for the specified call data. See the REDCap API documentation for more information.

Throws

IU\PHPCap\PhpCapException

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::call()
public string
+/- callWithArray( $dataArray )

Calls REDCap's API using a with a correctly formatted string version of the specified array and returns the results.

Calls REDCap's API using a with a correctly formatted string version of the specified array and returns the results.

Parameters

$dataArray

the array of data that is converted to a string and then passed to the REDCap API.

Returns

string

the response returned by the REDCap API for the specified call data. See the REDCap API documentation for more information.

Throws

IU\PHPCap\PhpCapException

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::callWithArray()
public array
+/- getCallInfo( )

Returns call information for the most recent call.

Returns call information for the most recent call.

Returns

array
an associative array of values of call information for the most recent call made.

Throws

IU\PHPCap\PhpCapException
if an error occurs and the default error handler is being used.

See

http://php.net/manual/en/function.curl-getinfo.php for information on what values are returned.


Implementation of

IU\PHPCap\RedCapApiConnectionInterface::getCallInfo()
public
+/- getErrorHandler( )

Gets the error handler for the connection.

Gets the error handler for the connection.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::getErrorHandler()
public
+/- setErrorHandler( IU\PHPCap\ErrorHandlerInterface $errorHandler )

Sets the error handler;

Sets the error handler;

Parameters

$errorHandler
the error handler to use.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::setErrorHandler()
public
+/- getUrl( )

Gets the URL of the connection.

Gets the URL of the connection.

return string the URL of the connection.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::getUrl()
public
+/- setUrl( string $url )

Sets the URL of the connection.

Sets the URL of the connection.

Parameters

$url
the URL of the connection.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::setUrl()
public boolean
+/- getSslVerify( )

Gets the status of SSL verification for the connection.

Gets the status of SSL verification for the connection.

Returns

boolean
true if SSL verification is enabled, and false otherwise.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::getSslVerify()
public
+/- setSslVerify( boolean $sslVerify )

Sets SSL verification for the connection.

Sets SSL verification for the connection.

Parameters

$sslVerify

if this is true, then the site being connected to will have its SSL certificate verified.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::setSslVerify()
public
+/- getCaCertificateFile( )
public
+/- setCaCertificateFile( $caCertificateFile )
public integer
+/- getTimeoutInSeconds( )

Gets the timeout in seconds for calls to the connection.

Gets the timeout in seconds for calls to the connection.

Returns

integer
timeout in seconds for calls to connection.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::getTimeoutInSeconds()
public
+/- setTimeoutInSeconds( $timeoutInSeconds )

Sets the timeout in seconds for calls to the connection.

Sets the timeout in seconds for calls to the connection.

Parameters

$timeoutInSeconds
in seconds for call to connection.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::setTimeoutInSeconds()
public integer
+/- getConnectionTimeoutInSeconds( )

Gets the timeout for time to make a connection in seconds.

Gets the timeout for time to make a connection in seconds.

Returns

integer
connection timeout in seconds.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::getConnectionTimeoutInSeconds()
public
+/- setConnectionTimeoutInSeconds( integer $connectionTimeoutInSeconds )

Sets the timeout for time to make a connection in seconds.

Sets the timeout for time to make a connection in seconds.

Parameters

$connectionTimeoutInSeconds
timeout in seconds.

Implementation of

IU\PHPCap\RedCapApiConnectionInterface::setConnectionTimeoutInSeconds()
public boolean
+/- setCurlOption( integer $option, mixed $value )

Sets the specified cURL option to the specified value.

Sets the specified cURL option to the specified value.

Parameters

$option
the cURL option that is being set.
$value
the value that the cURL option is being set to.

Returns

boolean
Returns true on success and false on failure.

See

http://php.net/manual/en/function.curl-setopt.php for information on cURL options.


public mixed
+/- getCurlOption( integer $option )

Gets the value for the specified cURL option number.

Gets the value for the specified cURL option number.

Parameters

$option
cURL option number.

Returns

mixed

if the specified option has a value that has been set in the code, then the value is returned. If no value was set, then null is returned. Note that the cURL CURLOPT_POSTFIELDS option value is not saved, because it is reset with every call and can can be very large. As a result, null will always be returned for this cURL option.

See

http://php.net/manual/en/function.curl-setopt.php for information on cURL options.


public
+/- __clone( )
Constants summary
integer DEFAULT_TIMEOUT_IN_SECONDS
+/- 1200
integer DEFAULT_CONNECTION_TIMEOUT_IN_SECONDS
+/- 20
PHPCap API documentation generated by ApiGen