MarketData SDK

ForbiddenException extends BadStatusCodeError
in package

Exception raised for 403 FORBIDDEN HTTP errors.

The Market Data API may include X-API-Authorized-IP when access is blocked because the caller's detected IP does not match the account's authorized IP.

Table of Contents

Properties

$authorizedIp  : string|null
The IP address currently authorized for the account.
$requestId  : string|null
$requestUrl  : string|null
$response  : ResponseInterface|null
$timestamp  : DateTimeImmutable

Methods

__construct()  : mixed
ForbiddenException constructor.
__toString()  : string
Get string representation of the exception.
getAuthorizedIp()  : string|null
Get the IP address currently authorized for the account.
getRequestId()  : string|null
Get the Cloudflare request ID for support tickets.
getRequestUrl()  : string|null
Get the URL that was requested when the error occurred.
getResponse()  : ResponseInterface|null
Get the HTTP response associated with this exception.
getSupportContext()  : array<string|int, mixed>
Get all support ticket context as an associative array.
getSupportInfo()  : string
Get a pre-formatted string with all information needed for a support ticket.
getTimestamp()  : DateTimeImmutable
Get the timestamp when the exception occurred.
extractRequestId()  : string|null
Extract the request ID (cf-ray header) from the response.

Properties

$authorizedIp

The IP address currently authorized for the account.

public string|null $authorizedIp

$requestId

protected string|null $requestId

The Cloudflare request ID (cf-ray header) for support tickets.

$requestUrl

protected string|null $requestUrl

The URL that was requested when the error occurred.

$response

protected ResponseInterface|null $response

The HTTP response associated with this exception.

$timestamp

protected DateTimeImmutable $timestamp

The timestamp when the exception occurred (stored in UTC).

Methods

__construct()

ForbiddenException constructor.

public __construct([string $message = "" ][, int $code = 403 ][, Throwable|null $previous = null ][, ResponseInterface|null $response = null ][, string|null $requestUrl = null ]) : mixed
Parameters
$message : string = ""

The exception message.

$code : int = 403

The exception code (should be 403).

$previous : Throwable|null = null

The previous exception used for exception chaining.

$response : ResponseInterface|null = null

The HTTP response associated with this exception.

$requestUrl : string|null = null

The URL that was requested when the error occurred.

__toString()

Get string representation of the exception.

public __toString() : string

Includes the standard exception information plus request context (timestamp, request ID, and URL) when available.

Return values
string

getAuthorizedIp()

Get the IP address currently authorized for the account.

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

getRequestId()

Get the Cloudflare request ID for support tickets.

public getRequestId() : string|null

This ID can be provided to Market Data support to help identify the specific request that failed.

Return values
string|null —

The request ID, or null if not available.

getRequestUrl()

Get the URL that was requested when the error occurred.

public getRequestUrl() : string|null
Return values
string|null —

The request URL, or null if not available.

getResponse()

Get the HTTP response associated with this exception.

public getResponse() : ResponseInterface|null
Return values
ResponseInterface|null —

The HTTP response.

getSupportContext()

Get all support ticket context as an associative array.

public getSupportContext() : array<string|int, mixed>

Get support context as an associative array.

Return values
array<string|int, mixed>

getSupportInfo()

Get a pre-formatted string with all information needed for a support ticket.

public getSupportInfo() : string

Get pre-formatted support ticket information.

Return values
string

getTimestamp()

Get the timestamp when the exception occurred.

public getTimestamp() : DateTimeImmutable

The timestamp is stored in UTC. Convert to your preferred timezone as needed:

$localTime = $e->getTimestamp()->setTimezone(new \DateTimeZone('America/Los_Angeles'));
Return values
DateTimeImmutable —

The timestamp when the exception was created (UTC).

extractRequestId()

Extract the request ID (cf-ray header) from the response.

protected extractRequestId(ResponseInterface|null $response) : string|null
Parameters
$response : ResponseInterface|null

The HTTP response.

Return values
string|null —

The request ID, or null if not available.

On this page

Search results