Add content to Facebook feed dialog box from Facebook SDK for Android

In my Android application, I want users to β€œshare” my application on their wall, so I want them to publish predefined content on their wall.

How to adjust the status of the wall? (I want to add my app icon and some flash text).

+7
source share
4 answers

Download the Facebook SDK and import it into your project. Then use the following code to log in:

public void sendtoFacebook(){ facebookClient = new Facebook("<Your_APP_ID"); facebookClient.authorize(<Current_class>.this, new AuthorizeListener()); } 

Now you need to add the following methods:

 class AuthorizeListener implements DialogListener { public void onComplete(Bundle values) { Bundle parameters = new Bundle(); parameters.putString("message", "<Message_you_want_to_send>");// the message to post to the wall facebookClient.dialog(<Current_class>.this, "stream.publish", parameters, this);// "stream.publish" is an API call } @Override public void onFacebookError(FacebookError e) { } @Override public void onError(DialogError e) { } @Override public void onCancel() { } } 

Your application name and icon will be added automatically :)

+5
source

Having studied the Facebook API, I came across this

So, now I know all the parameters of the package parameters. Thank you all for your help!

+3
source

You can also do this without the SDK, simply via the Share URL:

 public void shareOnFacebook(View v) { Uri uri = Uri.parse("http://m.facebook.com/sharer.php?u=http://yourdomain/page.html&t=YourMessage"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } 

You just need to place the content / html page somewhere on your server under the URL provided to your member.

If you want a specific image to appear in the general message, put it in the meta tag of your html page on the server you are sharing:

 <link rel="image_src" type="image/jpeg" href="http://yourdomain.com/promo/image.png" /> 

See a sample of such a promotional page with an associated image: http://www.modelme.co.uk/promo/amandaharrington

+2
source

Here's how I make a package to install content through the facebook dialog using the Facebook SDK

 Bundle parameters = new Bundle(); parameters.putString("app_id", "xxxxxxx"); parameters.putString("link", "https://play.google.com/store/apps/details?id=myappistasty"); parameters.putString("name", "This is the name of the link set in app."); parameters.putString("caption", "This is Text that is specified in bt the aoo"); parameters.putString("picture", "www.urltoimage.com); facebook.dialog(MainActivity.this, "feed", parameters, new DialogListener() { etc... 

http://developers.facebook.com/docs/reference/dialogs/feed/ is a link that explained everything to me, although not one of them in the java table gives you a good idea.

+2
source

All Articles