Tribe__Events__Aggregator__Service::post( string $endpoint, array $data = array() )
Performs a POST request against the Event Aggregator service
Contents
Parameters
- $endpoint
-
(string) (Required) Endpoint for the Event Aggregator service
- $data
-
(array) (Optional) Parameters to send to the endpoint
Default value: array()
Return
(stdClass|WP_Error)
Source
File: src/Tribe/Aggregator/Service.php
public function post( $endpoint, $data = array() ) { $url = $this->build_url( $endpoint ); // If we have an WP_Error we return it here if ( is_wp_error( $url ) ) { return $url; } if ( empty( $data['body'] ) ) { $args = array( 'body' => $data ); } else { $args = $data; } // if not timeout was set we pass it as 15 seconds if ( ! isset( $args['timeout'] ) ) { $args['timeout'] = 15; } $response = $this->requests->post( esc_url_raw( $url ), $args ); if ( is_wp_error( $response ) ) { return $response; } $json = json_decode( wp_remote_retrieve_body( $response ) ); if ( empty( $json ) ) { return tribe_error( 'core:aggregator:invalid-json-response', array( 'response' => $response ), array( 'response' => $response ) ); } return $json; }