RedCapApiConnection
in package
implements
RedCapApiConnectionInterface
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.
Interfaces, Classes, Traits and Enums
- RedCapApiConnectionInterface
- Interface for connection to the API of a REDCap instance.
Table of Contents
- DEFAULT_CONNECTION_TIMEOUT_IN_SECONDS = 20
- DEFAULT_TIMEOUT_IN_SECONDS = 1200
- __clone() : mixed
- __construct() : mixed
- Constructor that creates a REDCap API connection for the specified URL, with the specified settings.
- __destruct() : mixed
- Closes the cURL handle (if it is set).
- call() : string
- Makes a call to REDCap's API and returns the results.
- callWithArray() : string
- Calls REDCap's API using a with a correctly formatted string version of the specified array and returns the results.
- getCaCertificateFile() : mixed
- getCallInfo() : array<string|int, mixed>
- Returns call information for the most recent call.
- getConnectionTimeoutInSeconds() : int
- Gets the timeout for time to make a connection in seconds.
- getCurlOption() : mixed
- Gets the value for the specified cURL option number.
- getErrorHandler() : mixed
- Gets the error handler for the connection.
- getSslVerify() : bool
- Gets the status of SSL verification for the connection.
- getTimeoutInSeconds() : int
- Gets the timeout in seconds for calls to the connection.
- getUrl() : mixed
- Gets the URL of the connection.
- setCaCertificateFile() : mixed
- setConnectionTimeoutInSeconds() : int
- Sets the timeout for time to make a connection in seconds.
- setCurlOption() : bool
- Sets the specified cURL option to the specified value.
- setErrorHandler() : mixed
- Sets the error handler;
- setSslVerify() : mixed
- Sets SSL verification for the connection.
- setTimeoutInSeconds() : mixed
- Sets the timeout in seconds for calls to the connection.
- setUrl() : mixed
- Sets the URL of the connection.
Constants
DEFAULT_CONNECTION_TIMEOUT_IN_SECONDS
public
mixed
DEFAULT_CONNECTION_TIMEOUT_IN_SECONDS
= 20
DEFAULT_TIMEOUT_IN_SECONDS
public
mixed
DEFAULT_TIMEOUT_IN_SECONDS
= 1200
Methods
__clone()
public
__clone() : mixed
Return values
mixed —__construct()
Constructor that creates a REDCap API connection for the specified URL, with the specified settings.
public
__construct(mixed $url[, mixed $sslVerify = false ][, mixed $caCertificateFile = '' ][, mixed $errorHandler = null ]) : mixed
Parameters
- $url : mixed
-
the URL for the API of the REDCap site that you want to connect to.
- $sslVerify : mixed = false
-
indicates if verification should be done for the SSL connection to REDCap. Setting this to false is not secure.
- $caCertificateFile : mixed = ''
-
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 : mixed = null
-
the error handler for the connection.
Tags
Return values
mixed —__destruct()
Closes the cURL handle (if it is set).
public
__destruct() : mixed
Return values
mixed —call()
Makes a call to REDCap's API and returns the results.
public
call(mixed $data) : string
Parameters
- $data : mixed
-
data for the call.
Return values
string —the response returned by the REDCap API for the specified call data. See the REDCap API documentation for more information.
callWithArray()
Calls REDCap's API using a with a correctly formatted string version of the specified array and returns the results.
public
callWithArray(mixed $dataArray) : string
Parameters
- $dataArray : mixed
-
array the array of data that is converted to a string and then passed to the REDCap API.
Return values
string —the response returned by the REDCap API for the specified call data. See the REDCap API documentation for more information.
getCaCertificateFile()
public
getCaCertificateFile() : mixed
Return values
mixed —getCallInfo()
Returns call information for the most recent call.
public
getCallInfo() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —an associative array of values of call information for the most recent call made.
See http://php.net/manual/en/function.curl-getinfo.php for information on what values are returned.
getConnectionTimeoutInSeconds()
Gets the timeout for time to make a connection in seconds.
public
getConnectionTimeoutInSeconds() : int
Return values
int —connection timeout in seconds.
getCurlOption()
Gets the value for the specified cURL option number.
public
getCurlOption(int $option) : mixed
See http://php.net/manual/en/function.curl-setopt.php for information on cURL options.
Parameters
- $option : int
-
cURL option number.
Return values
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.
getErrorHandler()
Gets the error handler for the connection.
public
getErrorHandler() : mixed
Return values
mixed —getSslVerify()
Gets the status of SSL verification for the connection.
public
getSslVerify() : bool
Return values
bool —true if SSL verification is enabled, and false otherwise.
getTimeoutInSeconds()
Gets the timeout in seconds for calls to the connection.
public
getTimeoutInSeconds() : int
Return values
int —timeout in seconds for calls to connection.
getUrl()
Gets the URL of the connection.
public
getUrl() : mixed
return string the URL of the connection.
Return values
mixed —setCaCertificateFile()
public
setCaCertificateFile(mixed $caCertificateFile) : mixed
Parameters
- $caCertificateFile : mixed
Return values
mixed —setConnectionTimeoutInSeconds()
Sets the timeout for time to make a connection in seconds.
public
setConnectionTimeoutInSeconds(mixed $connectionTimeoutInSeconds) : int
Parameters
- $connectionTimeoutInSeconds : mixed
Return values
int —connection timeout in seconds.
setCurlOption()
Sets the specified cURL option to the specified value.
public
setCurlOption(int $option, mixed $value) : bool
See http://php.net/manual/en/function.curl-setopt.php for information on cURL options.
Parameters
- $option : int
-
the cURL option that is being set.
- $value : mixed
-
the value that the cURL option is being set to.
Return values
bool —Returns true on success and false on failure.
setErrorHandler()
Sets the error handler;
public
setErrorHandler(mixed $errorHandler) : mixed
Parameters
- $errorHandler : mixed
-
the error handler to use.
Return values
mixed —setSslVerify()
Sets SSL verification for the connection.
public
setSslVerify(mixed $sslVerify) : mixed
Parameters
- $sslVerify : mixed
-
if this is true, then the site being connected to will have its SSL certificate verified.
Return values
mixed —setTimeoutInSeconds()
Sets the timeout in seconds for calls to the connection.
public
setTimeoutInSeconds(mixed $timeoutInSeconds) : mixed
Parameters
- $timeoutInSeconds : mixed
-
timeout in seconds for call to connection.
Return values
mixed —setUrl()
Sets the URL of the connection.
public
setUrl(mixed $url) : mixed
Parameters
- $url : mixed
-
the URL of the connection.