This documentation includes a Quick Start that helps you to get started with your implementation. If you need more specified details look at the methods listed in left bar navigation.
First step is to get your Partner API-Key by signing up as a Partner.
Next you can create a new Channel in your partner account and define a appropriate search term that match the content you will display at your website. After a few minutes your channel will start collecting new material based on your channel settings.
Follow the steps below to create a list of pressreleases from your channel.
Include the Mynewsdesk JavaScript file code below in your HTML page. The JavaScript have to be included in all pages where you use Mynewsdesk JSAPI.
<script type="text/javascript" src="http://www.mynewsdesk.com/jsapi.js"></script>
Initialize the Mynewsdesk load method inside a script block with the channel feature and version specified. Include your private API-key and the id of the channel you will display material from (you can find both in your partner account). The callback is the name of the function to run when the channel API is loaded.
<script type="text/javascript" language="JavaScript">
mynewsdesk.load({
feature: "channels",
version: "1",
api_key: "INSERT_YOUR_API_KEY",
channel_id: "INSERT_YOUR_CHANNEL_ID",
callback: myCallbackFunction
});
</script>
Before we start with the list method call we need a element where we should place the content from Mynewsdesk JSAPI.
HTML element where the content from the request will be rendered.
<div id="list_content_holder">
Loaded HTML will replace this content
</div>
When the Channel feature is loaded, your callback function will be executed. In this example the callback function is defined as "myCallbackFunction" and within the function myCallbackFunction you can access all Channel methods.
The example below loads all Pressreleases within the channel and places the content in an element with id "list_content_holder". The setting "view_template_url" is your html page where you will show the full content of the pressrelease.
Below is an example callback function that execute the list method that updates content inside HTML element with id list_content_holder.
<script type="text/javascript" language="JavaScript">
function myCallbackFunction(){
mynewsdesk.channels.list("pressreleases", "list_content_holder",{
view_template_url: "view_pressreleases.html"
});
}
</script>
<html>
<head>
<title>List pressreleases</title>
<script type="text/javascript" src="http://www.mynewsdesk.com/jsapi.js"></script>
<script type="text/javascript" language="JavaScript">
mynewsdesk.load({
feature: "channels",
version: "1",
api_key: "INSERT_YOUR_API_KEY",
channel_id: "INSERT_YOUR_CHANNEL_ID",
callback: myCallbackFunction
});
function myCallbackFunction(){
mynewsdesk.channels.list("pressreleases", "list_content_holder",{
view_template_url: "view_pressreleases.html"
});
}
</script>
</head>
<body>
<div id="list_content_holder">
Loaded HTML will replace this content
</div>
</body>
</html>
You will now have a working list of Press Releases rendered to a HTML element at your webpage.
To view material you create a separate HTML page with the same name that you have used as template url for the list method (view_pressreleases.html) where you display the full content of the material. You will have to include the JavaScript file above and include the load of the channel feature.
When all required scripts are loaded you call the view method instead of the list method.
Below we execute the view method and display the content in an HTML element with id view_content_holder. The view method will automatically load the correct id for the clicked news item from the list view based on the id and type_of_media.
<script type="text/javascript" language="JavaScript">
function myCallbackFunction(){
mynewsdesk.channels.view("view_content_holder");
}
</script>
<html>
<head>
<title>View pressrelease</title>
<script type="text/javascript" src="http://www.mynewsdesk.com/jsapi.js"></script>
<script type="text/javascript" language="JavaScript">
mynewsdesk.load({
feature: "channels",
version: "1",
api_key: "INSERT_YOUR_API_KEY",
channel_id: "INSERT_YOUR_CHANNEL_ID",
callback: myCallbackFunction
});
function myCallbackFunction(){
mynewsdesk.channels.view("view_content_holder");
}
</script>
</head>
<body>
<div id="view_content_holder">
Loaded HTML will replace this content
</div>
</body>
</html>
The design of your implementation will be configured at the website where you use the JSAPI. Mostly the implementation will look good if you have a well designed stylesheet at your website. But sometimes you need to add some minor styles to get it looks proper. You can take a look at the example website for the styles and classes or just start explore the rendered code with Firebug or your favorite tool.
We have created a simple CSS with the most basic styles that you can add to your existing stylesheet as a start. This simple CSS is just some configuration for the headers in list where the source name and date are displayed. You will also have some basic font settings and it will remove the default bullets in list.
/*both list material and view material*/
span.source{
text-transform:uppercase;
}
span.date{
padding-left:10px;
font-style:italic;
}
/*List material (element with id=list_content_holder)*/
#list_content_holder ul{
margin:0;
padding:0;
list-style-type:none;
}
#list_content_holder h2 span.header{
font-size:14px;
display:block;
}
#list_content_holder h2 span{
font-size:12px;
}
/*View material (element with id=view_content_holder)*/
#view_content_holder h1{
font-size:18px;
}
We have created a simple example implementation of the Channel JSAPI, take a look and get inspired. The code is free to download and your are free to modify the code for your purposes.
Mynewsdesk example implementation of Channel JSAPI
You have to sign-up for a free Partner Account to get your API-key and start
Before you can use the JavaScript Channel API you have to load the feature from Mynewsdesk and define a callback function where you access the Channel API methods.
featureversionapi_keychannel_idcallbackcharset
<script type="text/javascript" src="http://www.mynewsdesk.com/jsapi.js"></script>
<script type="text/javascript" language="JavaScript">
mynewsdesk.load({
feature: "channels",
version: "1",
api_key: "INSERT_YOUR_API_KEY",
channel_id: "INSERT_YOUR_CHANNEL_ID",
callback: myCallbackFunction
});
function myCallbackFunction(){
mynewsdesk.channels.view("view_content_holder");
}
</script>
With the list method you will be able to list material from a Channel. Just one type_of_media or mix it all together.
type_of_mediaelement_idview_template_urlcallback
mynewsdesk.channels.list("type_of_media", "element_id",{
view_template_url: "view_pressreleases.html"
});
mynewsdesk.channels.list(["pressreleases","news"], "my_element_id",{
callback: "doIt"
});
function doIt(result){
document.getElementById(result.element).innerHTML = result.html;
}
With Channel View method you can display the full content of material from your channel.
element_idtype_of_mediaitem_idcallback
mynewsdesk.channels.view("element_id");
mynewsdesk.channels.view("my_element_id",{
type_of_media: "news"
});
mynewsdesk.channels.view("my_element_id",{
type_of_media: "news"
});