dimanche 25 mai 2014

Android post image to wall


Vote count:

0




I would like to load picture from sdcard and then post it to facebook wall. For now I find this code:



private void publishFeedDialog() {
Bundle params = new Bundle();
params.putString("name", "name");
params.putString("caption", "caption");
params.putString("description", "description");
params.putString("picture", "http://ift.tt/1aCEine");

WebDialog feedDialog = (
new WebDialog.FeedDialogBuilder(getActivity(),
Session.getActiveSession(),
params))
.setOnCompleteListener(new OnCompleteListener() {

@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(getActivity(),
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(getActivity().getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(getActivity().getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(getActivity().getApplicationContext(),
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}

})
.build();
feedDialog.show();
}


this works but how I can post image from my sdcard with this code? Is this possible or is there maybe another way. I saw a lot of code from old facebook api but I cant run it. I use lastest facebook api 3.14.



asked 1 min ago

AYMADA

194





Aucun commentaire:

Enregistrer un commentaire