I look all the internet and couldn’t find how do I post link with a specific picture on facebook wall using fb sdk\api.
I know that this is part of the code that I need to use:
Facebook facebookClient = new Facebook("fb_App_id");
Bundle parameters = new Bundle();
parameters.putString("message", "Test Photo");
parameters.putString("link", "https://www.google.com");
parameters.putString("picture", "link to some pictrue");
facebookClient.dialog(MainActivity.this, "stream.publish", parameters, new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
@Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
}
});
When I try to use this code I get “Source not found” error.
I think that I’m missing the connect\verification step…
How can I make it work?
Another thing: In case I use FB SDK in my personal app that I share on Google Play and this app is FREE but has Ads on it, Is it legal to use FB SDK in my app?
Finally I found how to do it.
You need to declare this two:
In the onCreate function I initialize facebookClient with the facebook AppID.
The class that lunches the facebook share must be Activity
There are three functions that I added to the activity:
and at last:
It does an auto login to facebook and then displaies facebook share\post dialog.
The code was taken from this tutorial