i am making a app in which there is this edit box and a share button when i click on the share button it posts my status on my LinkedIn account i tried social lib but its of no use kindly help me out how to post a status.
2 Answers
I got the answer after too much time spent to it. I have done using signpost lib and linkedin-j-android lib
As you got the token and secret token(if want to getting token and secret token you can see this tutorial for getting this from here) after that you can post share very easily just store this token and secret token in SharedPreference. like this way
LinkedInAccessToken accessToken = oauthservice.getOAuthAccessToken(liToken, oauth_verifier);
final Editor edit = prefs.edit();
edit.putString(OAuth.OAUTH_TOKEN, accessToken.getToken());
edit.putString(OAuth.OAUTH_TOKEN_SECRET, accessToken.getTokenSecret());
edit.putString("linkedin_login", "valid");
edit.commit();
now from another activity you can you use this token and secret as for Post Share first get the consumer object
private OAuthConsumer getConsumer() {
OAuthConsumer consumer = new CommonsHttpOAuthConsumer(LinkedinConstants.CONSUMER_KEY, LinkedinConstants.CONSUMER_SECRET);
consumer.setTokenWithSecret(token, secret);
return consumer;
}
now after getting consumer execute the REST Call using HttpPost
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost("https://api.linkedin.com/v1/people/~/shares");
consumer.sign(post); // here need the consumer for sign in for post the share
post.setHeader("content-type", "text/XML");
String myEntity = "<share><comment>This is a test</comment><visibility><code>anyone</code></visibility></share>";
post.setEntity(new StringEntity(myEntity));
org.apache.http.HttpResponse response = httpclient.execute(post);
as the shares post url so you need to set the message in the header part like above I have.
for the shares REST call see here
sorry for poor english :-)

- 30,639
- 18
- 84
- 159
-
Pratik, need your guide, would you let me know, your code is working on android 4.0 plus I am having error, communication fail with service provider followed by linkin api url – Abdul Wahab Mar 21 '13 at 09:04
-
Hi, Pratik, can you help me with [this](http://stackoverflow.com/questions/25971257/unable-to-authorize-linkedin-app-from-android) question.? – Aishvarya Jaiswal Sep 23 '14 at 07:43
Check out their REST API.
They've also got a good java wrapper for their API. Specifically check out this and this page.
There's an example on how to update status using the java wrapper available too, located here.

- 2,859
- 1
- 22
- 30
-
-
The example linked is fully working, adapt it to your needs. I doubt anyone will code the solution for you. – Joakim Berglund Oct 24 '11 at 13:16