how to post message on wall on LinkedIn in android -


i'm using selvin's code in apps..but not getting how post message on wall.. here code.. have refer link integration here posting linkedin message android application

package pl.osadkowski.litest; import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.net.uri; import android.os.bundle; import android.widget.textview; import android.widget.toast;  import com.google.code.linkedinapi.client.linkedinapiclient; import com.google.code.linkedinapi.client.linkedinapiclientexception; import com.google.code.linkedinapi.client.linkedinapiclientfactory; import com.google.code.linkedinapi.client.oauth.linkedinaccesstoken; import com.google.code.linkedinapi.client.oauth.linkedinoauthservice; import com.google.code.linkedinapi.client.oauth.linkedinoauthservicefactory; import com.google.code.linkedinapi.client.oauth.linkedinrequesttoken; import com.google.code.linkedinapi.schema.person;  public class litestactivity extends activity {      // /change keysssssssssssssssssssssssssssss!!!!!!!!!!      static final string consumer_key = "6oj6vol2hva6";     static final string consumer_secret = "rreh5pzhdgzxzmpq";      static final string app_name = "litest";     static final string oauth_callback_scheme = "x-oauthflow-linkedin";     static final string oauth_callback_host = "litestcalback";     static final string oauth_callback_url = string.format("%s://%s",             oauth_callback_scheme, oauth_callback_host);     static final string oauth_query_token = "oauth_token";     static final string oauth_query_verifier = "oauth_verifier";     static final string oauth_query_problem = "oauth_problem";      final linkedinoauthservice oauthservice = linkedinoauthservicefactory             .getinstance().createlinkedinoauthservice(consumer_key,                     consumer_secret);     final linkedinapiclientfactory factory = linkedinapiclientfactory             .newinstance(consumer_key, consumer_secret);      static final string oauth_pref = "likedin_oauth";     static final string pref_token = "token";     static final string pref_tokensecret = "tokensecret";     static final string pref_reqtokensecret = "requesttokensecret";      textview tv = null;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         tv = new textview(this);         setcontentview(tv);         final sharedpreferences pref = getsharedpreferences(oauth_pref,                 mode_private);         final string token = pref.getstring(pref_token, null);         final string tokensecret = pref.getstring(pref_tokensecret, null);         if (token == null || tokensecret == null) {             startautheniticate();         } else {             showcurrentuser(new linkedinaccesstoken(token, tokensecret));         }      }      void startautheniticate() {         final linkedinrequesttoken litoken = oauthservice                 .getoauthrequesttoken(oauth_callback_url);         final string uri = litoken.getauthorizationurl();         getsharedpreferences(oauth_pref, mode_private).edit()                 .putstring(pref_reqtokensecret, litoken.gettokensecret())                 .commit();         intent = new intent(intent.action_view, uri.parse(uri));         startactivity(i);     }      void finishauthenticate(final uri uri) {         if (uri != null && uri.getscheme().equals(oauth_callback_scheme)) {             final string problem = uri.getqueryparameter(oauth_query_problem);             if (problem == null) {                 final sharedpreferences pref = getsharedpreferences(oauth_pref,                         mode_private);                 final linkedinaccesstoken accesstoken = oauthservice                         .getoauthaccesstoken(                                 new linkedinrequesttoken(uri                                         .getqueryparameter(oauth_query_token),                                         pref.getstring(pref_reqtokensecret,                                                 null)),                                 uri.getqueryparameter(oauth_query_verifier));                 pref.edit()                         .putstring(pref_token, accesstoken.gettoken())                         .putstring(pref_tokensecret,                                 accesstoken.gettokensecret())                         .remove(pref_reqtokensecret).commit();                 showcurrentuser(accesstoken);             } else {                 toast.maketext(this,                         "appliaction down due oauth problem: " + problem,                         toast.length_long).show();                 finish();             }          }     }      void cleartokens() {         getsharedpreferences(oauth_pref, mode_private).edit()                 .remove(pref_token).remove(pref_tokensecret)                 .remove(pref_reqtokensecret).commit();     }      void showcurrentuser(final linkedinaccesstoken accesstoken) {         final linkedinapiclient client = factory                 .createlinkedinapiclient(accesstoken);         try {             final person p = client.getprofileforcurrentuser();         // /////////////////////////////////////////////////////////         // here can client api calls ...         // client.postcomment(arg0, arg1);         // client.updatecurrentstatus(arg0);         // or other api call (this sample check current user         // , shows in textview)         // /////////////////////////////////////////////////////////             tv.settext(p.getlastname() + ", " + p.getfirstname());         } catch (linkedinapiclientexception ex) {             cleartokens();             toast.maketext(                     this,                     "appliaction down due linkedinapiclientexception: "                             + ex.getmessage()                             + " authokens cleared - try run application again.",                     toast.length_long).show();             finish();         }      }      @override     protected void onnewintent(intent intent) {         finishauthenticate(intent.getdata());     } } 

plz provide me java , xml code well...thanks in advance

once got accesstoken got in finishauthenticate() method, write following code post update in asynctask's doinbackground method.

linkedinapiclient client = factory.createlinkedinapiclient(accesstoken);  client.postnetworkupdate(your_message_string); 

simple, isn't it?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -