GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
Licenses/Helpers.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @license GPL-2.0-or-later
4  *
5  * Modified by gravityview on 13-January-2023 using Strauss.
6  * @see https://github.com/BrianHenryIE/strauss
7  */
8 
10 
11 use Exception;
12 
13 class Helpers {
14  /**
15  * Performs remote call to GravityKit's EDD API.
16  *
17  * @sice 1.0
18  *
19  * @param string $url
20  * @param array $args
21  *
22  * @throws Exception
23  *
24  * @return array|null Response body.
25  */
26  static function query_api( $url, array $args = [] ) {
27  $request_parameters = [
28  'timeout' => 15,
29  'sslverify' => false,
30  'body' => $args,
31  ];
32 
33  $response = wp_remote_post(
34  $url,
35  $request_parameters
36  );
37 
38  if ( is_wp_error( $response ) ) {
39  throw new Exception( $response->get_error_message() );
40  }
41 
42  $body = wp_remote_retrieve_body( $response );
43 
44  if ( is_wp_error( $body ) ) {
45  throw new Exception( $response->get_error_message() );
46  }
47 
48  try {
49  $response = json_decode( $body, true );
50  } catch ( Exception $e ) {
51  throw new Exception( esc_html__( 'Unable to process remote request. Invalid response body.', 'gk-gravityview' ) );
52  }
53 
54  return $response;
55  }
56 }
$url
Definition: post_image.php:25
static query_api( $url, array $args=[])
Performs remote call to GravityKit&#39;s EDD API.