我正在尝试发布图片,消息,标题,link.expect图片剩余的发布很好。 如果我给图片的url它工作。但我想发送drawable image.image不发布 我试过下面的代码:
class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
publishFeedDialog();
}
public void onFacebookError(FacebookError error) {
showToast("Authentication with Facebook failed!");
finish();
}
public void onError(DialogError error) {
showToast("Authentication with Facebook failed!");
finish();
}
public void onCancel() {
showToast("Authentication with Facebook cancelled!");
finish();
}
}
private void publishFeedDialog() {
final Bundle params = new Bundle();
final Bitmap bit=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bit.compress(CompressFormat.JPEG, 100, baos);
byte[] data = baos.toByteArray();
params.putString("to", Universal.ids);
params.putString(Facebook.TOKEN, facebook.getAccessToken());
params.putString("name", "Sending a birthday card!");
params.putString("link", "https://play.google.com/store/search?q=dbgr&c=apps&hl=en");
params.putString("description", "Wishing You a HAPPY BIRTHDAY");
params.putString("picture", data);
facebook.dialog(this, "feed", params, new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
showToast("Authentication with Facebook failed!");
finish();
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
showToast("Authentication with Facebook failed!");
finish();
}
@Override
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
showToast("Post is successfully sent");
finish();
Intent i=new Intent(getApplicationContext(),FrndActivity.class);
startActivity(i);
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
showToast("Authentication with Facebook cancelled!");
finish();
}
});
图片不发布。请帮助我。
答案 0 :(得分:0)
Feed对话框的“picture”参数不支持上传位图,只支持网址。
https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.0