Jump to content

Validate response code from URL query


Aetherdan

Recommended Posts

// 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?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...