protected function ZoomAPI::sendRequest in Zoom API 7
Send Request.
22 calls to ZoomAPI::sendRequest()
- ZoomAPIMeeting::create in includes/
zoomapi.meeting.classes.inc - Create Meeting.
- ZoomAPIMeeting::delete in includes/
zoomapi.meeting.classes.inc - Delete Meeting.
- ZoomAPIMeeting::get in includes/
zoomapi.meeting.classes.inc - Get Meeting Info.
- ZoomAPIMeeting::list in includes/
zoomapi.meeting.classes.inc - List Meetings.
- ZoomAPIMeeting::live in includes/
zoomapi.meeting.classes.inc - List Live Meetings.
File
- includes/
zoomapi.classes.inc, line 46 - Base class for the Zoom API.
Class
- ZoomAPI
- Zoom API Base Class.
Code
protected function sendRequest($endpoint, $data = []) {
if (variable_get('zoomapi_debug', FALSE)) {
watchdog('zoomapi_debug', 'Request: @endpoint => !data', [
'@endpoint' => $endpoint,
'!data' => '<pre>' . print_r($data, TRUE) . '</pre>',
], WATCHDOG_DEBUG);
}
$request_url = $this->apiUrl . $endpoint;
$data['api_key'] = $this->apiKey;
$data['api_secret'] = $this->apiSecret;
$data['data_type'] = 'JSON';
drupal_alter('zoomapi_sendrequest', $request_url, $data);
$post_fields = drupal_http_build_query($data);
// Allow a site to disable sending requests for debug / development
// purposes. This may be useful because Zoom does not currently support prod
// vs test environments.
if (variable_get('zoomapi_sendrequests_enabled', TRUE)) {
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
} catch (Exception $e) {
watchdog('zoomapi', 'An error occurred making a call to !endpoint with data !data. Exception: @exception.', [
'!endpoint' => $endpoint,
'!data' => '<pre>' . print_r($data, TRUE) . '</pre>',
'@exception' => $e
->getMessage(),
], WATCHDOG_ERROR);
return [];
}
$response = drupal_json_decode($response);
if (variable_get('zoomapi_debug', FALSE)) {
watchdog('zoomapi_debug', 'Response: @endpoint => !response', [
'@endpoint' => $endpoint,
'!response' => '<pre>' . print_r($response, TRUE) . '</pre>',
], WATCHDOG_DEBUG);
}
if (isset($response['error'])) {
watchdog('zoomapi', 'An error occurred making a call to !endpoint with data !data. Error code: @code. Message: @message', [
'!endpoint' => $endpoint,
'!data' => '<pre>' . print_r($data, TRUE) . '</pre>',
'@code' => $response['error']['code'],
'@message' => $response['error']['message'],
], WATCHDOG_ERROR);
return [];
}
}
else {
$response = [
'error' => [
'code' => 0,
'message' => t('This site has disabled the zoomapi_sendrequests_enabled variable.'),
],
];
}
return $response;
}