NpsAtomClient is used to exchange data with others via Atom Publishing Protocol.
Below shows how to download articles from nps.myserver.com and publish to the 'news' topic at 'testsite' site.
and assume that NPS is deployed at nps.myserver.com.
|
var site = session.GetSite("testsite"); var topic = site.GetTopicByCode("news"); var client = new NpsAtomClient("http://nps.jwebstar.com/"); client.NpsLogin("/webapi/login","system","manager"); var articles = client.List("/webapi/posts/testsite/"); for(var i=0;i<articles.length;i++) { client.DownloadArticle(articles[i],topic); } client.Clear(); |
|
NpsAtomClient(String host) Constructor. host is the root URL we try to connect, for example, http://nps.jwebstar.com:8080/ |
|
| void |
HttpBasicLogin(String uri,String uid,String pwd) throws Exception Http Basic Authentication. |
| void |
GoogleLogin(String uri,String uid, String pwd, String service) throws Exception Google Authentication. |
| void |
NpsLogin(String uri,String uid,String pwd) throws Exception NPS Authentication. uri usually is '/webapi/login'. |
| void |
FormLogin(String uri,Object fieldnames,Object fieldvalues) throws Exception Sign in via posting form. fieldnames and fieldvalues are two array indicate fields to post. |
| NpsArticle |
DownloadArticle(String url,NpsTopic topic) throws Exception Download article from url and submit to topic, and return the article submitted. |
| NpsResource |
DownloadResource(String url,NpsSite site) throws Exception Download resource from url and save to site, and then return the resource. |
| NpsResource |
DownloadResourceAndPublishTo(String url,NpsTopic topic) throws Exception Download resource from url and generate a new article and submit it to topic, and then return the resource. |
| Object |
List(String url) throws Exception Parsing all datas listed in url and return an array including all links |
| void |
PostArticle(String url, NpsArticle nps_art) throws Exception Post the article to url |
| void |
PostResource(String url, NpsResource nps_resource) throws Exception Post the resource to url |
| void |
Delete(String url) throws Exception Delete article or resource |
| void |
Clear() Disconnect from server |