\ChapterThree\AppleNewsAPIPublisherAPI

AppleNewsAPI PublisherAPI

The PublisherAPI is a PHP library that allows you to publish content to Apple News. You can also retrieve, update and delete articles you've already published, and get basic information about your channel and sections.

Summary

Methods
Properties
Constants
__construct()
setHTTPClient()
get()
delete()
post()
__get()
__set()
__isset()
__unset()
triggerError()
$api_key_id
$api_key_secret
$endpoint
$client
$path
$method
$path_args
$datetime
EOL
VERSION
setHeaders()
unsetHeaders()
request()
response()
getFileInformation()
multipartPart()
multipartFinalize()
hhmac()
auth()
path()
initVars()
onSuccessfulResponse()
onErrorResponse()
$valid_mimes
N/A
No private methods found
$boundary
N/A

Constants

EOL

EOL

VERSION

VERSION

Properties

$api_key_id

$api_key_id : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) — PublisherAPI API Key ID.

$api_key_secret

$api_key_secret : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) — PublisherAPI Secret Key.

$endpoint

$endpoint : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) — PublisherAPI Endpoint base URL.

$client

$client : \ChapterThree\AppleNewsAPI\PublisherAPI\(object)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(object) — HTTP client class.

$path

$path : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) — Endpoint path.

$method

$method : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) — HTTP Method (GET/DELETE/POST).

$path_args

$path_args : \ChapterThree\AppleNewsAPI\PublisherAPI\(array)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) — Endpoint path variables to replace.

$datetime

$datetime : \ChapterThree\AppleNewsAPI\PublisherAPI\(datetime)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(datetime) — ISO 8601 datetime.

$valid_mimes

$valid_mimes : \ChapterThree\AppleNewsAPI\PublisherAPI\(array)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) — Valid values for resource part Content-Type.

$boundary

$boundary : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Type

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) — Multipat data boundary unique string.

Methods

__construct()

__construct(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $key, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $secret, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $endpoint) 

Initialize variables needed in the communication with the API.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $key

API Key.

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $secret

API Secret Key.

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $endpoint

API endpoint URL.

setHTTPClient()

setHTTPClient() 

Setup HTTP client to make requests.

get()

get(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $path, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $path_args, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $data) : object

Create GET request to a specified endpoint.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $path

Path to API endpoint.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $path_args

Endpoint path arguments to replace tokens in the path.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $data

Raw content of the request or associative array to pass to endpoints.

Returns

object —

Preprocessed structured object.

delete()

delete(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $path, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $path_args, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $data) : object

Create DELETE request to a specified endpoint.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $path

Path to API endpoint.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $path_args

Endpoint path arguments to replace tokens in the path.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $data

Raw content of the request or associative array to pass to endpoints.

Returns

object —

Preprocessed structured object and returns 204 No Content on success, with no response body.

post()

post(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $path, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $path_args, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $data) : object

Create POST request to a specified endpoint.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $path

Path to API endpoint.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $path_args

Endpoint path arguments to replace tokens in the path.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $data

Raw content of the request or associative array to pass to endpoints.

Returns

object —

Preprocessed structured object.

__get()

__get(\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed)  $name) 

Implements __get().

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed) $name

Property name.

__set()

__set(\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed)  $name, \ChapterThree\AppleNewsAPI\PublisherAPI\(mixed)  $value) 

Implements __set().

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed) $name

Property name.

\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed) $value

Property value.

__isset()

__isset(\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed)  $name) 

Implements __isset().

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed) $name

Property name.

__unset()

__unset(\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed)  $name) 

Implements __unset().

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(mixed) $name

Property name.

triggerError()

triggerError(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $message, \ChapterThree\AppleNewsAPI\PublisherAPI\(const)  $message_type = E_USER_NOTICE) 

Error handler.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $message

Error message to display.

\ChapterThree\AppleNewsAPI\PublisherAPI\(const) $message_type

Predefined Constants

setHeaders()

setHeaders(\ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $headers = array()) 

Set HTTP headers.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $headers

Associative array [header field name => value].

unsetHeaders()

unsetHeaders(\ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $headers = array()) 

Remove specified header names from HTTP request.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $headers

Associative array [header1, header2, ..., headerN].

request()

request(\ChapterThree\AppleNewsAPI\PublisherAPI\(array|\ChapterThree\AppleNewsAPI\PublisherAPI\string)  $data) : \ChapterThree\AppleNewsAPI\PublisherAPI\(object)

Create HTTP request.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(array|\ChapterThree\AppleNewsAPI\PublisherAPI\string) $data

Raw content of the request or associative array to pass to endpoints.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(object) —

HTTP Response object.

response()

response(\ChapterThree\AppleNewsAPI\PublisherAPI\(object)  $response) : \ChapterThree\AppleNewsAPI\PublisherAPI\(object)

Preprocess HTTP response.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(object) $response

Structured object.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(object) —

HTTP Response object.

getFileInformation()

getFileInformation(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $path) : \ChapterThree\AppleNewsAPI\PublisherAPI\(array)

Get file information and its contents to upload.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $path

Path to a file included in the POST request.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) —

Associative array. The array contains information about a file.

multipartPart()

multipartPart(\ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $attributes, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $mimetype = null, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $contents = null) : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Generate individual multipart data parts.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $attributes

Associative array with information about each file (mimetype, filename, size).

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $mimetype

Multipart mime type.

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $contents

Contents of the multipart content chunk.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) —

Raw HTTP multipart chunk formatted according to the RFC.

multipartFinalize()

multipartFinalize(\ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $multiparts = array()) : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Finalize multipart data.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $multiparts

Multipart data with its headers.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) —

Raw HTTP multipart data formatted according to the RFC.

hhmac()

hhmac(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $string, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $api_key_secret) : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Generate HMAC cryptographic hash.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $string

Message to be hashed.

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $api_key_secret

Shared secret key used for generating the HMAC.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) —

Authorization token used in the HTTP headers.

auth()

auth(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $string = '') : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Create canonical version of the request as a byte-wise concatenation.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $string

String to concatenate (see POST method).

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) —

HMAC cryptographic hash

path()

path() : \ChapterThree\AppleNewsAPI\PublisherAPI\(string)

Generate HTTP request URL.

Returns

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) —

URL to create request.

initVars()

initVars(\ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $method, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $path, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $path_args, \ChapterThree\AppleNewsAPI\PublisherAPI\(array)  $data) 

Initialize variables needed to make a request.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $method

Request method (POST/GET/DELETE).

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $path

Path to API endpoint.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $path_args

Endpoint path arguments to replace tokens in the path.

\ChapterThree\AppleNewsAPI\PublisherAPI\(array) $data

Data to pass to the endpoint.

onSuccessfulResponse()

onSuccessfulResponse(\ChapterThree\AppleNewsAPI\PublisherAPI\(object)  $response) 

Callback for successful HTTP response.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(object) $response

HTTP Response object.

onErrorResponse()

onErrorResponse(\ChapterThree\AppleNewsAPI\PublisherAPI\(int)  $error_code, \ChapterThree\AppleNewsAPI\PublisherAPI\(string)  $error_message, \ChapterThree\AppleNewsAPI\PublisherAPI\(object)  $response) 

Callback for error HTTP response.

Parameters

\ChapterThree\AppleNewsAPI\PublisherAPI\(int) $error_code

HTTP status code.

\ChapterThree\AppleNewsAPI\PublisherAPI\(string) $error_message

HTTP status message.

\ChapterThree\AppleNewsAPI\PublisherAPI\(object) $response

Structured object.