HTTP Requests with Caching (GET/POST)

Thin wrapper around wp_remote_get/wp_remote_post with internal cache and optional JSON decoding. Respects proxy settings from options.

// GET example (auto json_decode by default):
$data = CFGP_U::curl_get('https://api.example.com/geo?ip=8.8.8.8');
if ( $data ) {
    // $data is an array
}

// POST example (custom headers and params)
$data = CFGP_U::curl_post(
    'https://api.example.com/convert',
    ['amount' => 100, 'from' => 'USD', 'to' => 'EUR'],
    ['Accept: application/json'],
    ['timeout' => 10]
);
Was this page helpful?