In my android app, I want users to "share" my app in their wall, so I want them to post a predefined content status on their wall.
How can I customize the wall status? (I want to add my app icon and some flare text).
Download the Facebook SDK and import it in your project. Then use the following code to Authorize:
public void sendtoFacebook(){
facebookClient = new Facebook("<Your_APP_ID");
facebookClient.authorize(<Current_class>.this, new AuthorizeListener());
}
Now you have to add the following methodes:
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 automatically be added :)
After learning the Facebook API, I came across this page
so now I know all the options for the bundle parameters. Thanks everyone for your help!
You can also do that without the SDK, just via 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 put a content page / html somewhere on your server, under the url your provided to the sharer.
If you want that a certain image appears in the shared message, put this in the meta tag of your html page on the server that you're sharing:
<link rel="image_src" type="image/jpeg" href="http://yourdomain.com/promo/image.png" />
See a sample of such promo page with linked image: http://www.modelme.co.uk/promo/amandaharrington
This is how I am making a bundle to set content via a 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/ this is the link that explained all to me, although none of it is in java the table gives you a good idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With