Looking to pull some live content such as the weather or school classifieds into your OneCampus instance? An active content JSON feed is a great way to display that info!
You can add an active content JSON feed to any task or task center to have live content displayed directly on the task tile as well as on the task detail page. For example, you might want to add a feed that shows items for sale (similar to the image above for a Classifieds task) or list hours of operation for the library or list outage alerts for the IT services department.
Active Content Task Configuration
- Configure the task or task center like you would any other (see the Quick Guides for Tasks and Task Centers) until you get to the Active Content Section that is located at the bottom of the task or task center screen.
- In the Active Content Public URL field, please provide a https URL to a JSON feed for the content you wish to showcase on the task tile as well as on the task detail page.
The currently supported JSON format is as follows:
{
"tileContent" : [
{
"text" : ["Content for the first line on the first page", "line two of first page"]
}, {
"text" : ["Some content for page 2", "", "skipped a line on this page"]
}
]
}
Up to 5 pieces of content are allowed inside the tileContent array. Any additional items will be truncated.The text field inside of each tileContent is an array of strings. Each string starts a new line in the content. If a line is too long to fit inside the tile, then it will continue as an ellipsis (series of dots).
As an option, when the data is requested, additional request parameters are used to indicate the role(s) and market (campus) currently selected by the user in order to customize the data field if desired. If the Required user to be signed in checkbox is checked, then we will send a request parameter of userName={userName}.
https://www.url.edu/feed.json?roles[]=role1&roles[]=role2&market=iupui&userName=0000000001
If you provide an API key, then we send a request parameter of user={encryptedUser|encryptedTimestamp} instead of the userName as well as a request parameter of timestamp={unix timestamp}.
Valid values for roles and the market are the unique keys for roles and markets as they are defined for the current tenant.
- Enter an API Key. An API key will be required for authorized feeds. For example if the feed will include sensitive, user-specific data, such as PTO hours or money that remains on an end user's campus dining plan, then you should provide an API key. If the feed will contain general data, such as open hours for a store location or the daily weather, then you do not need an API key. If an API key is provided, we will encode a user parameter in the request that will be made up of the "username|timestamp" as well as provide a parameter in the request called timestamp to verify the encoding.
- Api Key is a 128-bit key that OneCampus uses to secure the communications with the system providing the active content.
- We use a static init vector of "RandomInitVector" in a UTF-8 spec as well as a cipher of "AES/CBC/PKCS5PADDING" in conjunction with the API key when we encode.
- We have provided a Generate Key button on this screen to generate a 128-bit API key for you, if need be.
- Use the Test button to verify that the active content is being retrieved correctly.
- If an error occurs, and your JSON contains an "errorMessage" field, we will display the contents of this field.
- If an error occurs, and your JSON does not contain an “errorMessage” field, we will show you a standard error message.
- In either case, we will show you the URL that we used to communicate with your Active Content feed to help you troubleshoot.
- If this test doesn't work, try to test your feed from the command line using the method provided below in the notes section of this document.
- Before clicking Save or Submit at the bottom of the task or task center screen, you also have the option to do the following:
- Check the box for Active Content Authentication if you wish to execute Active Content only when a user is logged in. [Optional]
- If checked, public content will not begin scrolling on the task tile until a user authenticates. Please note: All secured feeds will require a user to be logged in, as such, there is no need to check this box if your JSON is a secure feed.
Unauthenticated Authenticated
- If checked, public content will not begin scrolling on the task tile until a user authenticates. Please note: All secured feeds will require a user to be logged in, as such, there is no need to check this box if your JSON is a secure feed.
- Use Update Frequency to indicate the interval (in seconds) that you would like the Active Content (live JSON feed) to update once the tile has been displayed. [Optional]
Please note: This field updates the frequency interval with which the end user's browser will go out to get updated data. It does not update how fast the data is scrolled or shown on the task tile. - You can also choose a Tile Height preference from the drop down. [Optional]
- Normal will allow five pages, up to six lines of content per page, one line at a time.
- Double will allow five pages, up to six lines of content per page, one page at a time.
- Normal will allow five pages, up to six lines of content per page, one line at a time.
- Check the box for Active Content Authentication if you wish to execute Active Content only when a user is logged in. [Optional]
Notes:
- It is important to note that you must use SSL-enabled “https” URL’s for Active Content JSON feeds. Modern web browsers block “mixed content” and since OneCampus is secured using “https”, browsers will block any request we send to a “http” url.
- The tile content format is only partially flexible - if you find your JSON content is not displaying correctly, please revert to the sample format and test again.
-
We have added two active content endpoints in OneCampus for testing purposes. Edit the URLs below to match your tenant.
- https://yoururl.edu/activeContent
- https://yoururl.edu/securedActiveContent (Please note that this test will require an API key AND it must be the same key as the NOTIFICATIONS-API-KEY under Maintain Settings in your tenant.)
-
It may be necessary for you to Enable CORS (Cross-Origin Resource Sharing) on the feed server.
-
Tomcat instructions: http://enable-cors.org/server_tomcat.html
Add in a filter to the web.xml file in Tomcat.
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping> -
Apache instructions: https://enable-cors.org/server_apache.html
Even simpler here, just add the following to http.conf:
Header set Access-Control-Allow-Origin "*"
Because this is a potential cross-domain AJAX call, be aware that CORS may need to be properly configured on the servers providing the data.
-
Tomcat instructions: http://enable-cors.org/server_tomcat.html
-
If your test using the test button in step 3 is unsuccessful, you may test your feed from the command line by using the following:
curl -H "Origin: http://example.com" \
-H "Access-Control-Request-Method: GET" \
-H "Access-Control-Request-Headers: X-Requested-With" \
-X OPTIONS --verbose \
https://{insertyourdomain}
[URL OF FEED]
This will return a long result but the key thing you should see is the following along with the actual output:
< Access-Control-Allow-Origin: https://{insertyourdomain}
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET
Related to
Updated