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

Commit

Permalink
Merge pull request #44 from INN/11-https-regex
Browse files Browse the repository at this point in the history
switch to https urls in the DS_NPR_API class
  • Loading branch information
benlk authored Apr 16, 2018
2 parents 053aaf7 + d0b1f61 commit 9d3b111
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Travis CI Configuration File

# Use Travis CI container-based infrastructure
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
# See: https://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

# Tell Travis CI we're using PHP
Expand Down Expand Up @@ -75,7 +75,7 @@ branches:
# Clones WordPress and configures our testing environment.
before_script:
- export SLUG=$(basename $(pwd))
- svn co --quiet http://develop.svn.wordpress.org/tags/$WP_VERSION $WP_CORE_DIR
- svn co --quiet https://develop.svn.wordpress.org/tags/$WP_VERSION $WP_CORE_DIR
- cd ..
- mv $SLUG "$WP_CORE_DIR/src/wp-content/plugins/$SLUG"
- cd $WP_CORE_DIR
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <https://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ Stable tag: 1.6

License: GPLv2

License URI: http://www.gnu.org/licenses/gpl-2.0.html
License URI: https://www.gnu.org/licenses/gpl-2.0.html

== Description ==

The NPR Story API Plugin provides push and pull functionality with the NPR API 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 get 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 to NPR's legacy APIs. If you are an NPR member station or are working with an NPR member station and do not know your key, please [https://nprsupport.desk.com/customer/login?return_to=%2Fcustomer%2Fportal%2Femails%2Fnew] (ask NPR station relations for help).
Access to the NPR API requires an API Key to NPR's legacy APIs. If you are an NPR member station or are working with an NPR member station and do not know your key, please [ask NPR station relations for help](https://nprsupport.desk.com/customer/login?return_to=%2Fcustomer%2Fportal%2Femails%2Fnew).

The WordPress plugin is being developed as an Open Source plugin by NPR. 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 [https://nprsupport.desk.com/customer/login?return_to=%2Fcustomer%2Fportal%2Femails%2Fnew] (NPR station relations).
The WordPress plugin is being developed as an Open Source plugin by NPR. 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 [NPR station relations](https://nprsupport.desk.com/customer/login?return_to=%2Fcustomer%2Fportal%2Femails%2Fnew).

== Installation ==

Expand All @@ -35,19 +35,19 @@ The WordPress plugin is being developed as an Open Source plugin by NPR. If you

= Can anyone get an NPR API Key? =

We are no longer provisioning public API key for our legacy APIs. If you are an NPR member station or are working with an NPR member station and do not know your key, please [https://nprsupport.desk.com/customer/login?return_to=%2Fcustomer%2Fportal%2Femails%2Fnew] (ask NPR station relations for help).
We are no longer provisioning public API key for our legacy APIs. If you are an NPR member station or are working with an NPR member station and do not know your key, please [ask NPR station relations for help](https://nprsupport.desk.com/customer/login?return_to=%2Fcustomer%2Fportal%2Femails%2Fnew).

= Can anyone push content into the NPR API using this plugin? =

Push requires an Organization ID in the NPR API, which is typically given out to only NPR stations and approved content providers. If that's you, you probably already have an Organization ID.

= Where can I find NPR's documentation on the NPR API? =

There is some documentation in the NPR API site: [http://www.npr.org/api/index.php](http://www.npr.org/api/index.php).
There is some documentation in the NPR API site: [https://www.npr.org/api/index.php](https://www.npr.org/api/index.php).

= Is there an easy way to directly query the NPR API? =

You bet, just visit the NPR Query Generator: [http://www.npr.org/api/queryGenerator.php](http://www.npr.org/api/queryGenerator.php)
You bet, just visit the NPR Query Generator: [https://www.npr.org/api/queryGenerator.php](https://www.npr.org/api/queryGenerator.php)

== Screenshots ==

Expand Down Expand Up @@ -104,7 +104,7 @@ NPR Stories having got gotten
* Multiple Bylines for pulled stories - When an API story has multiple bylines, we will now populate a meta field `npr_multi_byline` with a pipe (|) deliminated list of names. If the author also has a link for thier byline then there'll be a tilde (~) separating the author's name and the link.
- An example of data for multiple bylines:

Ari Shapiro~http://www-s2.npr.org/people/2101154/ari-shapiro|[email protected]|Tommy Writer
Ari Shapiro~https://www.npr.org/people/2101154/ari-shapiro|[email protected]|Tommy Writer

- Here there are three authors for this story, Ari Shapiro (and his bio link), then "[email protected]" and a third author "Tommy Writer". Single author stories will not be changed. (This fix came from Ryan Tainter at KERA. Thanks, Ryan!)

Expand All @@ -114,7 +114,7 @@ NPR Stories having got gotten

* Reversed the order of images and audio that are being pushed to the NPR API. We're now sending them in the order the file was created.
* Mapping of media credit and agency - If you have a field that you are storing image credit and agency, you can now send these to the NPR API. In making this change we needed to expose meta fields that begin with an underscore. So you may see more meta fields visable on the mapping page.
* Multiple bylines are now being pushed to the NPR API if you use the plugin co-author-plus (<http://wordpress.org/plugins/co-authors-plus/>) We insert a byline row for each of the co-authors of a post when we push. You can still use a custom byline field if you want to use that along with the co-authors plugin.
* Multiple bylines are now being pushed to the NPR API if you use the plugin co-author-plus (<https://wordpress.org/plugins/co-authors-plus/>) We insert a byline row for each of the co-authors of a post when we push. You can still use a custom byline field if you want to use that along with the co-authors plugin.
* Retrieved story dates - Now when you retrieve a story from the NPR API the published date for WordPress will be the date from the <storyDate> field in the NPR API. This will better allow stories to fall into their natural order when publishing from the Get Multi page. It's always possible to edit the date by hand when pulling single stories from the NPR API. Do remember though that you are contractually obligated to show the original date when rendering a story from the NPR API.
* Retrieved story order - When you retrieve stories from the API, if you do not include a `sort` parameter in your query, we will insure that the order of the stories is in reverse cron for any stories that have the same storyDate in the API. Often some aggregate groups in the API will publish stories with the same storyDate. Shows like Morning Edition do this often, and prior to this fix stories would appear to be published in reverse order from what the API shows. Now if you do not include `sort` in your query, the stories with the same time will be published in the same order as the API shows them.
* Configurable Cron interval - When you use the Get Multi page, which fires off of wp-cron, you can now set the interval for the wp-cron to fire. This is on the Get Multi configuration page, and allows you to enter a number of minutes you want as your wp-cron interval. If you enter any thing that is not a number, or a number less than 1, we will resolve that to 60 minutes...because, well, that's a resonable interval, and the wp-cron doesn't understand 'every now and then' as an interval.
Expand All @@ -137,7 +137,7 @@ NPR Stories having got gotten

= V1.3 =

* Permissions - If you have created any NPR API Permissions Groups you can select which (if any) group you would like to use as your default group when pushing content to the NPR API. Learn more about NPR API Permissions Groups here: <http://digitalservices.npr.org/post/npr-api-content-permissions-control>
* Permissions - If you have created any NPR API Permissions Groups you can select which (if any) group you would like to use as your default group when pushing content to the NPR API. Learn more about NPR API Permissions Groups here: <https://digitalservices.npr.org/post/npr-api-content-permissions-control>
* Multi-Site - Cron set up and other activation tasks will now happen on every site in a multi-site configuration.
* Cron queries - We won't try to query for any of the configured queries on the Get Multi page if the field isn't filled in with data.
* Content and short codes - Instead of blindly removing all shortcodes from a story's content, we are now trying to let any plugins replace the shortcodes with HTML, and then if there are any leftover shortcodes (we delete those?).
Expand All @@ -154,10 +154,10 @@ This version will allow admins to configure their WordPress site to retrieve mul

* From the Admin -> Settings -> NPR API Get Multi page (wp-admin/options-general.php?page=ds_npr_api_get_multi_settings) an admin can add a number of queries.
* These query entries can contain an API ID for a single story, or an ID for a specific category, program, topic, etc.
* The query can also contain the full query string can be created from the NPR API Query Generator: <http://www.npr.org/api/queryGenerator.php>
* The query can also contain the full query string can be created from the NPR API Query Generator: <https://www.npr.org/api/queryGenerator.php>
* You can also enter the URL for a story you found on npr.org.
* The entered queries will be executed via the Wordpress cron functionality, hourly.
* Any new stories that are available will be automatically published. You can find a list of query filters at the npr.org's API documentation page: <http://www.npr.org/api/inputReference.php>
* Any new stories that are available will be automatically published. You can find a list of query filters at the npr.org's API documentation page: <https://www.npr.org/api/inputReference.php>
* Stories retrieved from the NPR API will be created as Posts in WordPress. Each post will have a number of meta fields associated with the post. These meta fields will all begin with `npr_` and can be viewed on a post edit screen with Custom Fields option enabled through Screen Options. A story from the API that has a primary image defined will have that image set as the featured image of the Wordpress post. Any bylines for the NPR Story will be stored in the meta field `npr_byline`. The list of npr_ meta fields is:

npr_api_link
Expand All @@ -178,11 +178,11 @@ This version will allow admins to configure their WordPress site to retrieve mul
As not a lot of users have installed the V1.0 of the NPR API Plugin, there are a couple of things to keep in mind.

* On the NPR API settings page (wp-admin/options-general.php?page=ds_npr_api) there are 4 fields.
- API KEY - This is your NPR API Key that you can get from NPR. If you wish to push stories to the NPR API you'll need to have your key configured by NPR Digital Services. Please contact Digital Services with a support request at <http://info.ds.npr.org//support.html>
- Pull URL - This is the root url for retrieving stories. For testing purposes, you should configure this to be `http://api-s1.npr.org`. NOTE: this url should not contain a trailing slash.
- Push URL - Much like the pull url, this url is used to pushing stories to the NPR API. Again, for testing purposes, you can utilize NPR's staging server at `http://api-s1.npr.org`. If you do not wish to push your content, or your NPR API has not been authorized, you should leave this field empty and the WordPress plugin will not attempt to push you content to the NPR API.
- Org ID - This is your organization's ID assigned by NPR. If you don't know your Org ID, please contact Digital Services at: <http://info.ds.npr.org/support.html>
* You can pull stories one at a time from the NPR API by using the Get NPR Stories page under admin Posts menu (wp-admin/edit.php?page=get-npr-stories). This can be story ID from the API, or the URL for the story from npr.org. For help in finding possible query options, please use the Query Generator at <http://www.npr.org/api/queryGenerator.php> Documentation is at: <http://www.npr.org/api/inputReference.php>
- API KEY - This is your NPR API Key that you can get from NPR. If you wish to push stories to the NPR API you'll need to have your key configured by NPR Digital Services. Please contact Digital Services with a support request at <https://info.ds.npr.org//support.html>
- Pull URL - This is the root url for retrieving stories. For testing purposes, you should configure this to be `https://api-s1.npr.org`. NOTE: this url should not contain a trailing slash.
- Push URL - Much like the pull url, this url is used to pushing stories to the NPR API. Again, for testing purposes, you can utilize NPR's staging server at `https://api-s1.npr.org`. If you do not wish to push your content, or your NPR API has not been authorized, you should leave this field empty and the WordPress plugin will not attempt to push you content to the NPR API.
- Org ID - This is your organization's ID assigned by NPR. If you don't know your Org ID, please contact Digital Services at: <https://info.ds.npr.org/support.html>
* You can pull stories one at a time from the NPR API by using the Get NPR Stories page under admin Posts menu (wp-admin/edit.php?page=get-npr-stories). This can be story ID from the API, or the URL for the story from npr.org. For help in finding possible query options, please use the Query Generator at <https://www.npr.org/api/queryGenerator.php> Documentation is at: <https://www.npr.org/api/inputReference.php>

== Upgrade Notice ==

Expand Down
4 changes: 2 additions & 2 deletions classes/NPRAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class NPRAPI {
const NPRAPI_STATUS_OK = 200;

// Default URL for pulling stories
const NPRAPI_PULL_URL = 'http://api.npr.org';
const NPRAPI_PULL_URL = 'https://api.npr.org';

// NPRML CONSTANTS
const NPRML_DATA = '<?xml version="1.0" encoding="UTF-8"?><nprml></nprml>';
const NPRML_NAMESPACE = 'xmlns:nprml=http://api.npr.org/nprml';
const NPRML_NAMESPACE = 'xmlns:nprml=https://api.npr.org/nprml';
const NPRML_VERSION = '0.92.2';

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/NPRAPIWordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NPRAPIWordpress extends NPRAPI {
*
*
* @param string $path
* The path part of the request URL (i.e., http://example.com/PATH).
* The path part of the request URL (i.e., https://example.com/PATH).
*
* @param string $base
* The base URL of the request (i.e., HTTP://EXAMPLE.COM/path) with no trailing slash.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "nprds/nprapi-wordpress",
"description": "Access the NPR API from within Wordpress",
"homepage" : "http://digitalservices.npr.org/",
"homepage" : "https://digitalservices.npr.org/",
"type" : "wordpress-plugin",
"license" : "GPL-2.0+"
}
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Contributing

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 [http://info.ds.npr.org/support.html](http://info.ds.npr.org/support.html).
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).
6 changes: 3 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
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 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](http://www.npr.org/account/signup).
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).

The Push URL for the NPR Production API is `https://api.npr.org`.
The Push URL for the NPR Production API is `https://api.npr.org`.

The Push URL for testing purposes is `https://api-s1.npr.org`.

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

You can easily push posts to the [NPR One mobile app](http://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 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 "Send to 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 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 want to push a post to NPR One, check the box and hit the Publish or Update button.
Loading

0 comments on commit 9d3b111

Please sign in to comment.