You can use the social network library for direct publication on selected social networks without any code errors.
I use ASNE , it is really simple and can not only publish, but also log in or get friends
Edit : as @benka advised adding the code, as I did the posting on social networks in my application:
Add a dependency on the selected social network (facebook and twitter, but ASNE contains more):
dependencies { ... compile 'com.github.asne:asne-facebook:0.2.1' compile 'com.github.asne:asne-twitter:0.2.1' ... }
Just add mSocialNetworkManager from ASNE
mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(SOCIAL_NETWORK_TAG); if (mSocialNetworkManager == null) { mSocialNetworkManager = new SocialNetworkManager(); FacebookSocialNetwork fbNetwork = new FacebookSocialNetwork(this, fbScope); mSocialNetworkManager.addSocialNetwork(fbNetwork); TwitterSocialNetwork twNetwork = new TwitterSocialNetwork(this, key, secret); mSocialNetworkManager.addSocialNetwork(twNetwork); getFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_NETWORK_TAG).commit(); }
Show buttons for sharing their custom buttons in the action bar menu, and finally check input and usage
socialNetwork.requestPostMessage("Message");
that's all i need to get a friends list and i just add
socialNetwork.requestGetFriends();
source share