Sunday, 4 November 2012

Using Abdera Client creating an entry in the blog of Ibm Connections3.0

//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();
        }

No comments:

Post a Comment

Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...