Example #1
0
<?php

/**
 * @file
 * Example: Delete articles
 */
require '../../src/PublisherAPI.php';
use ChapterThree\AppleNewsAPI;
$api_key_id = "";
$api_key_secret = "";
$endpoint = "https://endpoint_url";
$PublisherAPI = new PublisherAPI($api_key_id, $api_key_secret, $endpoint);
// Deletes an article.
$response = $PublisherAPI->Delete('/articles/{article_id}', ['article_id' => '[ARTICLE_ID]']);
Example #2
0
<?php

/**
 * @file
 * Example: POST Article
 */
require '../../src/PublisherAPI.php';
use ChapterThree\AppleNewsAPI;
$api_key_id = "";
$api_key_secret = "";
$endpoint = "https://endpoint_url";
$PublisherAPI = new PublisherAPI($api_key_id, $api_key_secret, $endpoint);
// An optional metadata part may also be included, to provide additional
// non-Native data about the article. The metadata part also specifies any
// sections for the article, by URL. If this part is omitted,
// the article will be published to the channel's default section.
$metadata = ['data' => ['isSponsored' => true, 'links' => ['sections' => ['https://endpoint_url/sections/{your_section_id}']], '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], ['json' => '{"version":"0.10.13","identifier":"10","title":"Test article","language":"en","layout":{"columns":7,"width":1024},"components":[{"text":"Test article content\\n\\n","format":"markdown","role":"body"},{"URL":"bundle:\\/\\/article.jpg","role":"photo"}],"componentTextStyles":{"default":{}}}', 'files' => ['bundle://article.jpg' => __DIR__ . '/files/article.jpg'], 'metadata' => json_encode($metadata, JSON_UNESCAPED_SLASHES)]);
Example #3
0
<?php

/**
 * @file
 * Example: GET Channel
 */
require '../../src/PublisherAPI.php';
use ChapterThree\AppleNewsAPI;
$api_key_id = "";
$api_key_secret = "";
$endpoint = "https://endpoint_url";
$PublisherAPI = new PublisherAPI($api_key_id, $api_key_secret, $endpoint);
// Fetches information about a channel.
$response = $PublisherAPI->Get('/channels/{channel_id}', ['channel_id' => '[CHANNEL_ID]']);
Example #4
0
<?php

/**
 * @file
 * Example: GET Section
 */
require '../../src/PublisherAPI.php';
use ChapterThree\AppleNewsAPI;
$api_key_id = "";
$api_key_secret = "";
$endpoint = "https://endpoint_url";
$PublisherAPI = new PublisherAPI($api_key_id, $api_key_secret, $endpoint);
// Fetches information about a single section.
$response = $PublisherAPI->Get('/sections/{section_id}', ['section_id' => '[SECTION_ID]']);