FacebookReviews::request( string $url, bool|null $associative = false )

Request.


Parameters Parameters

$url

(string) (Required) URL

$associative

(bool|null) (Optional) [optional] When true, returned objects will be converted into associative arrays.

Default value: false


Top ↑

Return Return

(mixed) $response The body of the response. Empty string if no body or incorrect parameter given.


Top ↑

Source Source

File: mortgage-facebook-review/inc/FacebookReviews.php

	protected function request(string $url, $associative = false ){
		$response = get_transient(md5($url));
		if(!$response) {
			$response = wp_remote_get( $url, array(
					"headers" => array(
						'Content-Type' => 'application/json',
					)
				)
			);
			$response = wp_remote_retrieve_body( $response );

			$response = json_decode( $response, $associative );
			set_transient( md5( $url ), $response, DAY_IN_SECONDS );

		}
		return $response;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.