Twilio_Helpers::api_call( mixed $body, mixed $action = null )

api_call


Parameters Parameters

$body

(Required)

$action

(Optional)

Default value: null


Top ↑

Return Return

(void)


Source Source

File: src/integrations/twilio/helpers/twilio-helpers.php

	public function api_call( $body, $action = null ) {

		$client = $this->get_client();

		$body['account_sid'] = $client['account_sid'];
		$body['auth_token'] = $client['auth_token'];
		
		$params = array(
			'endpoint' => self::API_ENDPOINT,
			'body' => $body,
			'action' => $action
		);

		$response = Api_Server::api_call( $params );

		if ( 200 !== $response['statusCode'] ) {
			throw new \Exception( $params['endpoint'] . ' failed' );
		}

		return $response['data'];
	
	}