XF 2.0 Method to Replace cURL

Mythotical

Well-known member
#1
Ok I have this so far, I'm not sure if I need more but before I test, I wanted to make sure I have what I need.

PHP:
        $requestLink = $region.'wow/realm/status?locale='. $locale .'&apikey=' . $options->xenwow_api_key;

        try
        {
            $results = $this->app->http()->client()->get($requestLink);
        }
        catch(\GuzzleHttp\Exception\RequestException $e)
        {
            \XF::logException($e, false, "Error gathering data from $requestLink: ");
        }
All variables in $requestLink are defined above it and properly set.
 

Sim

Well-known member
#2
That should do it, and to retrieve the results (assuming you're still using Guzzle v5.3 as supplied with XF2), you would use $results->getBody() or if it's a json response, you can automatically decode using $results->json().
 
Top