Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted May 7, 20187 yr // Create a URL object $url = \IPS\Http\Url::external( $API_URL ); // Now fetch it try { $response = $url->request()->get(); } catch( \IPS\Http\Request\Exception $e ) { return FALSE; } catch( \RuntimeException $e ) { return FALSE; } if ($response->httpResponseCode == 200) { return TRUE; } else { return FALSE: } Is this the correct way to validate that a url request is successful?
May 7, 20187 yr Yes, assuming that you consider a response code other than 200 to be unsuccessful (many APIs, for instance, may return response codes other than 200 validly).
Archived
This topic is now archived and is closed to further replies.