Apple News API PHP Client

AuthenticationException extends AppleNewsException
in package

Exception thrown specifically when API authentication fails (401/403 errors).

Table of Contents

Properties

$errorCode  : string|null
$keyPath  : string|null

Methods

__construct()  : mixed
fromResponse()  : self
Factory method to create an exception from a standard API error response.
getErrorCode()  : string|null
Get the specific Apple News API error code (e.g., INVALID_REVISION).
getKeyPath()  : string|null
Get the path to the field that failed validation.

Properties

$errorCode

protected string|null $errorCode = null

The specific Apple News API error code.

$keyPath

protected string|null $keyPath = null

The field path in the request that caused the error.

Methods

__construct()

public __construct([string $message = '' ][, int $code = 0 ][, Throwable|null $previous = null ][, string|null $errorCode = null ][, string|null $keyPath = null ]) : mixed
Parameters
$message : string = ''

Exception message.

$code : int = 0

HTTP status code.

$previous : Throwable|null = null

Previous exception.

$errorCode : string|null = null

API-specific error code.

$keyPath : string|null = null

Field path where error occurred.

fromResponse()

Factory method to create an exception from a standard API error response.

public static fromResponse(array<string, mixed> $response[, int $httpCode = 0 ]) : self
Parameters
$response : array<string, mixed>

Decoded JSON error response.

$httpCode : int = 0

HTTP status code from the response.

Return values
self

getErrorCode()

Get the specific Apple News API error code (e.g., INVALID_REVISION).

public getErrorCode() : string|null
Return values
string|null

getKeyPath()

Get the path to the field that failed validation.

public getKeyPath() : string|null
Return values
string|null

        
On this page

Search results