Apple News API PHP Client

ArticleResponse
in package

FinalYes

Complete response from Create, Read, and Update Article endpoints.

This class provides a typed representation of the article data returned by the Apple News API, including metadata, state information, throttling data, and any warnings generated during processing.

Tags
see
https://developer.apple.com/documentation/applenewsapi/articleresponse

Table of Contents

Properties

$createdAt  : DateTimeImmutable|null
$id  : string
$isCandidateToBeFeatured  : bool|null
$isHidden  : bool|null
$isPreview  : bool|null
$isSponsored  : bool|null
$links  : ArticleLinks|null
$maturityRating  : string|null
$meta  : Meta|null
$modifiedAt  : DateTimeImmutable|null
$rawData  : array<string, mixed>
$revision  : string
$shareUrl  : string|null
$state  : ArticleState|null
$title  : string
$type  : string
$warnings  : array<string|int, mixed>

Methods

__construct()  : mixed
Create a new ArticleResponse instance.
fromApiResponse()  : self
Create an ArticleResponse instance from the raw API response.
getThrottling()  : Throttling|null
Get throttling information from the response.
hasWarnings()  : bool
Check if the response contains any warnings.

Properties

$createdAt read-only

public DateTimeImmutable|null $createdAt = null

$isCandidateToBeFeatured read-only

public bool|null $isCandidateToBeFeatured = null

$modifiedAt read-only

public DateTimeImmutable|null $modifiedAt = null

$rawData read-only

public array<string, mixed> $rawData = []

Raw response data for any fields not explicitly mapped

Methods

__construct()

Create a new ArticleResponse instance.

public __construct(string $id, string $type, string $title, string $revision[, ArticleState|null $state = null ][, string|null $shareUrl = null ][, DateTimeImmutable|null $createdAt = null ][, DateTimeImmutable|null $modifiedAt = null ][, bool|null $isSponsored = null ][, bool|null $isPreview = null ][, bool|null $isCandidateToBeFeatured = null ][, bool|null $isHidden = null ][, string|null $maturityRating = null ][, ArticleLinks|null $links = null ][, Meta|null $meta = null ][, array<int, Warning> $warnings = [] ][, array<string, mixed> $rawData = [] ]) : mixed
Parameters
$id : string

The unique identifier for the article.

$type : string

The resource type (always "article").

$title : string

The article title from the Apple News Format document.

$revision : string

The current revision token for optimistic locking.

$state : ArticleState|null = null

The current processing state of the article.

$shareUrl : string|null = null

The public URL to the article in Apple News.

$createdAt : DateTimeImmutable|null = null

When the article was first created.

$modifiedAt : DateTimeImmutable|null = null

When the article was last modified.

$isSponsored : bool|null = null

Whether the article is marked as sponsored content.

$isPreview : bool|null = null

Whether the article is in preview mode.

$isCandidateToBeFeatured : bool|null = null

Whether the article can be featured in Apple News.

$isHidden : bool|null = null

Whether the article is hidden from feeds.

$maturityRating : string|null = null

Content maturity rating (KIDS, GENERAL, MATURE).

$links : ArticleLinks|null = null

Related API resource URLs.

$meta : Meta|null = null

Metadata including throttling information.

$warnings : array<int, Warning> = []

Non-fatal warnings from the API.

$rawData : array<string, mixed> = []

Raw response data for unmapped fields.

fromApiResponse()

Create an ArticleResponse instance from the raw API response.

public static fromApiResponse(array<string, mixed> $response) : self

This factory method handles the nested structure of the API response, extracting data from the 'data', 'links', and 'meta' keys as appropriate.

Parameters
$response : array<string, mixed>

The full API response array.

Return values
self —

A new ArticleResponse instance populated with the response data.

getThrottling()

Get throttling information from the response.

public getThrottling() : Throttling|null

Convenience method to access throttling data without navigating through the meta object.

Return values
Throttling|null —

The throttling information, or null if not available.

hasWarnings()

Check if the response contains any warnings.

public hasWarnings() : bool
Return values
bool —

True if there are one or more warnings.


        
On this page

Search results