Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Version 1.8 #58

Merged
merged 7 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 75 additions & 69 deletions README.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/field-mapping.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# NPR API Field Mapping
# NPR Story API Field Mapping

In most cases your posts will successfully push to the NPR API using the standard WordPress fields including the post title and body. If your WordPress site has post types that use custom fields, you can map those fields to the NPR Story API using the settings in **Settings > NPR API Field Mapping**.
In most cases your posts will successfully push to the NPR Story API using the standard WordPress fields including the post title and body. If your WordPress site has post types that use custom fields, you can map those fields to the NPR Story API using the settings in **Settings > NPR API Field Mapping**.

Select your custom fields to map them to the NPR API labels:
Select your custom fields to map them to the NPR Story API labels:

![NPR API push settings for custom fields](assets/img/npr-api-wp-plugin-field-mapping.png)
![NPR Story API push settings for custom fields](assets/img/npr-api-wp-plugin-field-mapping.png)

Don't forget to click **Save Changes**!
Don't forget to click **Save Changes**!
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
1. Download the plugin files from this repository
2. Unzip and upload the unzipped plugin folder to the `/wp-content/plugins/` directory of your WordPress install OR go to **Plugins > Add New** from the WordPress dashboard and upload the plugin zip file
3. Activate the plugin through the **Plugins** screen in WordPress
4. Use the **Settings > NPR API** screen to configure the plugin. Begin by entering your API Key, then add your Push URL and Org ID.
4. Use the **Settings > NPR Story API** screen to configure the plugin. Begin by entering your API Key, then add your Push URL and Org ID.

If you don't have an API Key or Org ID you can request them by [registering for an NPR account](https://secure.npr.org/oauth2/login).

Expand Down
10 changes: 5 additions & 5 deletions docs/npr-one.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Pushing Posts to NPR One
# Pushing Posts to NPR One

You can easily push posts to the [NPR One mobile app](https://www.npr.org/about/products/npr-one/) in addition to the NPR API.
You can easily push posts to the [NPR One mobile app](https://www.npr.org/about/products/npr-one/) in addition to the NPR Story API.

After you [set up the WordPress NPR API Plugin](settings.md) with your API Key and Org ID, you will see a new checkbox in the Post Edit screen for "Include for listening in NPR One":
After you [set up the WordPress NPR Story API Plugin](settings.md) with your API Key and Org ID, you will see a new checkbox in the Post Edit screen for "Include for listening in NPR One":

![Send to NPR One checkbox in the WordPress post edit screen](assets/img/test-post-npr-one.png)

The checkbox is not selected by default. This allows you to push all your stories to the NPR API, but only selected stories to NPR One.
The checkbox is not selected by default. This allows you to push all your stories to the NPR Story API, but only selected stories to NPR One.

If you want to push a post to NPR One, check the box and hit the Publish or Update button.

If you are sending the story to NPR One, you can also choose to mark the story as a featured story in NPR One.
If you are sending the story to NPR One, you can also choose to mark the story as a featured story in NPR One.
20 changes: 10 additions & 10 deletions docs/pulling-multiple-stories.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# Pulling Multiple Stories from the NPR API By Custom API Query
# Pulling Multiple Stories from the NPR Story API By Custom API Query

You can set up and save one or more API queries to pull content based on topic, program, and other filters of your choosing. Once saved, these queries will retrieve new stories every hour, or any time interval you set.

In the WordPress Dashboard go to **Settings > NPR API Get Multi**. This screen offers several **Query String** fields where you can enter a query string for the NPR API.
In the WordPress Dashboard go to **Settings > NPR API Get Multi**. This screen offers several **Query String** fields where you can enter a query string for the NPR Story API.

![NPR API plugin settings for getting multiple stories](assets/img/wp-npr-api-get-multi-settings.png)
![NPR Story API plugin settings for getting multiple stories](assets/img/wp-npr-api-get-multi-settings.png)

Note that "Query String" simply means a URL containing query parameters like a Subject ID, content type, date range, number of results to return, etc. An NPR API query string looks something like this:
Note that "Query String" simply means a URL containing query parameters like a Subject ID, content type, date range, number of results to return, etc. An NPR Story API query string looks something like this:

`https://api.npr.org/query?id=1014,2&requiredAssets=audio&startDate=2016-04-01&endDate=2016-06-05&dateType=story&output=NPRML&numResults=10`

You can enter multiple query strings to pull content for different subjects, programs, etc., and set how often the queries will run. Once you save one or more queries, WordPress will continue to run them against the NPR API and return fresh stories as WordPress Posts or Drafts.
You can enter multiple query strings to pull content for different subjects, programs, etc., and set how often the queries will run. Once you save one or more queries, WordPress will continue to run them against the NPR Story API and return fresh stories as WordPress Posts or Drafts.

## How to Create a Query String

You can easily create query strings for API content by visiting the [NPR API Query Generator](https://www.npr.org/api/queryGenerator.php). The Query Generator provides a graphical user interface to create queries by topic, blogs, program, series, stations, and other values in the NPR API. Note that the **Control** tab of the Query Generator adds filtering by date or date range, search terms, and content type. You can also specify the number of results to return for a given query.
You can easily create query strings for API content by visiting the [NPR Story API Query Generator](https://www.npr.org/api/queryGenerator.php). The Query Generator provides a graphical user interface to create queries by topic, blogs, program, series, stations, and other values in the NPR Story API. Note that the **Control** tab of the Query Generator adds filtering by date or date range, search terms, and content type. You can also specify the number of results to return for a given query.

After creating a query in the Query Generator, click the button to **Create API Call**:

![Creating a query in the NPR API Query Generator](assets/img/npr-api-query-generator.png)
![Creating a query in the NPR Story API Query Generator](assets/img/npr-api-query-generator.png)

After you click the button to create your API call, you'll find the full URL of the query in the **Generated API Call** window:

![a query URL in the NPR API Query Generator](assets/img/npr-api-query-url.png)
![a query URL in the NPR Story API Query Generator](assets/img/npr-api-query-url.png)

Now copy the API call string up to the last segment `&apiKey=demo`. Do not include this in copying the query string. _(That segment would only be useful if you were going to run the query in the Query Generator itself, which we're not doing here.)_

Now that you've created and copied a query string, return to your WordPress Dashboard and the **Settings > NPR API Get Multi** page. Paste the string into one of the Query String fields. Use the dropdown menu to set whether stories returned from the API should be saved as Drafts or Posts:

![a query URL entered in the Query String field in WordPress](assets/img/npr-api-multiple-get-settings.png)

When you click **Save Changes**, WordPress will begin pulling NPR API content. Note that it may take up to an hour before stories begin showing up as Posts or Drafts.
When you click **Save Changes**, WordPress will begin pulling NPR Story API content. Note that it may take up to an hour before stories begin showing up as Posts or Drafts.

You can add more queries any time. If you run out of Query String fields, just increase the **Number of things to get** setting to add more fields.

Expand All @@ -46,6 +46,6 @@ Now you can edit any pulled story much like any other post. Although note that u

## Updating Pulled Stories

NPR often updates stories and pushes the updates to the NPR API. The same is true for other sources of content in the NPR API. You can easily update any stories you pulled from the API by visiting the **Posts** screen for your NPR Pull Post Type, and using the **Update NPR Story** Bulk Action:
NPR often updates stories and pushes the updates to the NPR Story API. The same is true for other sources of content in the NPR Story API. You can easily update any stories you pulled from the API by visiting the **Posts** screen for your NPR Pull Post Type, and using the **Update NPR Story** Bulk Action:

![Bulk Action menu link for Updating NPR Stories](assets/img/bulk-actions-update-npr-story.png)
8 changes: 4 additions & 4 deletions docs/pulling-single-story.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pulling a Single Story from the NPR API
# Pulling a Single Story from the NPR Story API

Once you have the [NPR API Plugin configured](/docs/settings.md), you can easily pull a story from the API into WordPress using a Story ID or URL.
Once you have the [NPR Story API Plugin configured](/docs/settings.md), you can easily pull a story from the API into WordPress using a Story ID or URL.

In the WordPress Dashboard under **Posts** you will see a link for **Get NPR Stories**:

Expand Down Expand Up @@ -30,6 +30,6 @@ Stories in the NPR Story API contain a lot of metadata. When you pull a story fr

If you don't see these custom fields in the post edit screen, click **Screen Options** in the upper right and then the checkbox for Custom Fields.

## Using NPR API Custom Fields in your WordPress theme
## Using NPR Story API Custom Fields in your WordPress theme

The custom fields generated by the NPR API provide a lot of flexibility for displaying API content in various ways. If you are familiar with WordPress theming, you could customize your WordPress theme to use the custom fields in your templates. For a reference on how to use these additional fields in your theme, refer to [the relevant documentation](https://codex.wordpress.org/Custom_Fields) in the WordPress Codex.
The custom fields generated by the NPR Story API provide a lot of flexibility for displaying API content in various ways. If you are familiar with WordPress theming, you could customize your WordPress theme to use the custom fields in your templates. For a reference on how to use these additional fields in your theme, refer to [the relevant documentation](https://codex.wordpress.org/Custom_Fields) in the WordPress Codex.
20 changes: 10 additions & 10 deletions docs/pushing.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Pushing Stories to the NPR API
# Pushing Stories to the NPR Story API

You can push any of your posts to the NPR API by checking the "Send to NPR API" box in the "NPR Story API" meta box in the post editor. Once this box is checked, publishing the post or saving an updated version of a published post will send the post to the NPR API.
You can push any of your posts to the NPR Story API by checking the "Send to NPR Story API" box in the "NPR Story API" meta box in the post editor. Once this box is checked, publishing the post or saving an updated version of a published post will send the post to the NPR Story API.

![Push to NPR button in the post edit screen](assets/img/push-to-npr-api.png)

By default any standard WordPress post can be pushed to the NPR API. If you have a custom post type you want to reserve for stories pushed to the API, you can select this in the **Settings > NPR API > NPR Push Post Type** setting, and only those posts will be pushed.
By default any standard WordPress post can be pushed to the NPR Story API. If you have a custom post type you want to reserve for stories pushed to the API, you can select this in the **Settings > NPR Story API > NPR Push Post Type** setting, and only those posts will be pushed.

![NPR API plugin settings page](assets/img/npr-api-wp-plugin-settings.png)
![NPR Story API plugin settings page](assets/img/npr-api-wp-plugin-settings.png)

## Verifying Pushed Stories

Expand All @@ -16,16 +16,16 @@ After publishing the post and pushing it to NPR we can easily verify that it was

If the push fails you will instead see an error message in a custom field named `npr_push_story_error`:

![NPR API push error message](assets/img/npr-api-push-error.png)
![NPR Story API push error message](assets/img/npr-api-push-error.png)

If you get push errors, check **Settings > NPR API** to make sure correct values are entered for your API Key, Pull URL, Push URL, Org ID, and NPR Push Post Type. (See the [NPR API Plugin Settings page for details](settings.md).)
If you get push errors, check **Settings > NPR API** to make sure correct values are entered for your API Key, Pull URL, Push URL, Org ID, and NPR Push Post Type. (See the [NPR Story API Plugin Settings page for details](settings.md).)

If you don't see these custom fields in the post edit screen, click **Screen Options** in the upper right and then the checkbox for Custom Fields.

## Pushing Story Updates to the NPR API
## Pushing Story Updates to the NPR Story API

If you edit a story that's previously been pushed to the NPR API, the changes will be pushed to the NPR API.
If you edit a story that's previously been pushed to the NPR Story API, the changes will be pushed to the NPR Story API.

## Deleting Posts from the NPR API
## Deleting Posts from the NPR Story API

You can delete any of your stories from the NPR API by simply deleting them in WordPress. Stories you pull from the API can't be deleted in this way, as you only have delete access to stories pushed to the API from your WordPress site.
You can delete any of your stories from the NPR Story API by simply deleting them in WordPress. Stories you pull from the API can't be deleted in this way, as you only have delete access to stories pushed to the API from your WordPress site.
14 changes: 7 additions & 7 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# NPR API Plugin Docs
# NPR Story API Plugin Docs

The NPR Story API Plugin provides push and pull functionality with the [NPR API](https://www.npr.org/api/index) along with a user-friendly administrative interface.
The NPR Story API Plugin provides push and pull functionality with the [NPR Story API](https://www.npr.org/api/index) along with a user-friendly administrative interface.

NPR's API is a content API, which essentially provides a structured way for other computer applications to pull NPR stories in a predictable, flexible and powerful way. The content that is available includes audio from most NPR programs dating back to 1995 as well as text, images and other web-only content from NPR and NPR member stations. This archive consists of over 250,000 stories that are grouped into more than 5,000 different aggregations.
NPR's Story API is a content API, which essentially provides a structured way for other computer applications to pull NPR stories in a predictable, flexible and powerful way. The content that is available includes audio from most NPR programs dating back to 1995 as well as text, images and other web-only content from NPR and NPR member stations. This archive consists of over 250,000 stories that are grouped into more than 5,000 different aggregations.

Access to the NPR API requires an API Key which you can get by [registering for an NPR account](https://secure.npr.org/oauth2/login).
Access to the NPR Story API requires an API Key which you can get by [registering for an NPR account](https://secure.npr.org/oauth2/login).

The WordPress plugin is being developed as an Open Source plugin by NPR Digital Services. If you would like to suggest features or bug fixes, or better yet if you would like to contribute new features or bug fixes please contact Digital Services through our support page at [https://info.ds.npr.org/support.html](https://info.ds.npr.org/support.html).

## Docs Table of Contents

- [Installation](installation.md)
- [Plugin Settings](settings.md)
- [Pulling a Single Story from the NPR API](pulling-single-story.md)
- [Pulling Multiple Stories from the NPR API By Custom API Query](pulling-multiple-stories.md)
- [Pushing Content to the NPR API](pushing.md)
- [Pulling a Single Story from the NPR Story API](pulling-single-story.md)
- [Pulling Multiple Stories from the NPR Story API By Custom API Query](pulling-multiple-stories.md)
- [Pushing Content to the NPR Story API](pushing.md)
- [Pushing Content to the NPR One app](npr-one.md)
- [Custom Field Mapping](field-mapping.md)
12 changes: 6 additions & 6 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Before you start

To pull content from the NPR API you'll need an API Key. Please contact [NPR's Member Partnership team](https://nprsupport.desk.com/customer/login) to acquire a key.
To pull content from the NPR Story API you'll need an API Key. Please contact [NPR's Member Partnership team](https://nprsupport.desk.com/customer/login) to acquire a key.

If you are planning to push content to the NPR API you'll also need an NPR API Org ID. If you are an NPR station or affiliated producer you can find your Org ID at [NPR StationConnect](https://stationconnect.org/login?redirect=%2F).
If you are planning to push content to the NPR Story API you'll also need an NPR Story API Org ID. If you are an NPR station or affiliated producer you can find your Org ID at [NPR StationConnect](https://stationconnect.org/login?redirect=%2F).

If you don't have an Org ID or don't intend to push content into the NPR API you can still pull content from the API, but be mindful of the [Terms of Use](https://www.npr.org/about-npr/179876898/terms-of-use).
If you don't have an Org ID or don't intend to push content into the NPR Story API you can still pull content from the API, but be mindful of the [Terms of Use](https://www.npr.org/about-npr/179876898/terms-of-use).

## Configure your settings

Expand All @@ -18,10 +18,10 @@ For NPR Pull Post Type you can leave the default or pick a custom post type. You

For NPR Push Post Type you can leave the default or set it to another post type, like `post`.

If you have configured any Permissions Groups for content you distribute through the NPR API you can optionally add them in the NPR Permissions setting. Note that by default all content in the NPR API is open to everyone, unless you restrict access to a Permissions Group. For more on setting these up see the [NPR API Content Permissions Control page](https://nprsupport.desk.com/customer/en/portal/articles/1995557-npr-api-content-permissions-control).
If you have configured any Permissions Groups for content you distribute through the NPR Story API you can optionally add them in the NPR Permissions setting. Note that by default all content in the NPR Story API is open to everyone, unless you restrict access to a Permissions Group. For more on setting these up see the [NPR Story API Content Permissions Control page](https://nprsupport.desk.com/customer/en/portal/articles/1995557-npr-api-content-permissions-control).

Once you have all the above entered your settings panel should look something like this:

![NPR API plugin settings page with values filled in as described above](assets/img/npr-api-wp-plugin-settings.png)
![NPR Story API plugin settings page with values filled in as described above](assets/img/npr-api-wp-plugin-settings.png)

Hit **Save Changes** and you're ready to start using the NPR API.
Hit **Save Changes** and you're ready to start using the NPR Story API.
2 changes: 1 addition & 1 deletion ds-npr-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: NPR Story API
* Description: A collection of tools for reusing content from NPR.org supplied by Digital Services.
* Version: 1.7.1
* Version: 1.8
* Author: NPR Digital Services
* License: GPLv2
*/
Expand Down
Loading