//Creating an entry in the blog
try{//surround with try catch
Abdera abdera = new Abdera();
String new_Title = "sample_entry";
AbderaClient client = new AbderaClient(abdera);
client.addCredentials(AuthScope.ANY_HOST, AuthScope.ANY_REALM,
AuthScope.ANY_SCHEME, new UsernamePasswordCredentials(StringConstants.USERNAME,StringConstants.PASSWORD));//passing credentials username/password
ClientResponse resp = client.get("https://x.y..com/blogs/"+communityID+"/api/entries");
Entry entry = abdera.newEntry();//creating a new entry
entry.addAuthor("xyz");
entry.setTitle(new_Title);
entry.addCategory("partner");
entry.addCategory("demo");
entry.setContentAsHtml(reviewContent);
resp = client.post(resp.getUri(), entry);//posting the entry
statusCode = resp.getStatus();
System.out.println("Status -->: "+resp.getStatus());//printing the status code
}catch(Exception e){
e.printStackTrace();
}
try{//surround with try catch
Abdera abdera = new Abdera();
String new_Title = "sample_entry";
AbderaClient client = new AbderaClient(abdera);
client.addCredentials(AuthScope.ANY_HOST, AuthScope.ANY_REALM,
AuthScope.ANY_SCHEME, new UsernamePasswordCredentials(StringConstants.USERNAME,StringConstants.PASSWORD));//passing credentials username/password
ClientResponse resp = client.get("https://x.y..com/blogs/"+communityID+"/api/entries");
Entry entry = abdera.newEntry();//creating a new entry
entry.addAuthor("xyz");
entry.setTitle(new_Title);
entry.addCategory("partner");
entry.addCategory("demo");
entry.setContentAsHtml(reviewContent);
resp = client.post(resp.getUri(), entry);//posting the entry
statusCode = resp.getStatus();
System.out.println("Status -->: "+resp.getStatus());//printing the status code
}catch(Exception e){
e.printStackTrace();
}
No comments:
Post a Comment