1. Go to this page and download the library: Download yorknouse/apple-news-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yorknouse / apple-news-api example snippets
use ChapterThree\AppleNewsAPI\Document;
use ChapterThree\AppleNewsAPI\Document\Components\Body;
use ChapterThree\AppleNewsAPI\Document\Layouts\Layout;
use ChapterThree\AppleNewsAPI\Document\Styles\ComponentTextStyle;
$obj = new Document(uniqid(), 'title', 'en', new Layout(7, 1024));
$obj->addComponent(new Body('body text'))
->addComponentTextStyle('default', new ComponentTextStyle());
$json = $obj->json();
// Publishes a new article to a channel.
// $response contains an article ID and revision ID.
$response = $PublisherAPI->post('/channels/{channel_id}/articles',
[
'channel_id' => CHANNEL_ID
],
[
// List of files to POST
'files' => [], // optional. A list of article assets [uri => path]
// JSON metadata string
'metadata' => $metadata, //
// Metadata information `revision` is [
'revision' => REVISION_ID
]
]);
// Updates an existing article.
// See $response variable to get a new revision ID.
$response = $PublisherAPI->post('/articles/{article_id}',
[
'article_id' => ARTICLE_ID
],
[
// List of files to POST
'files' => [], // optional. A list of article assets [uri => path]
// JSON metadata string
'metadata' => $metadata, //