我正在使用下一个代码将图像发布到用户的 Facebook 墙上:
private void postImageToWall(Session session) {
// Bitmap image = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "demo.jpg");
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.frame_with_woman);
Bundle parameters = new Bundle();
parameters.putParcelable("source", image);
parameters.putString("message", "my message for the page");
Request request = new Request(Session.getActiveSession(), "me/photos", parameters, HttpMethod.POST, new Request.Callback() {
@Override
public void onCompleted(Response response) {
LogService.log(TAG, "Successfully posted");
}
});
request.executeAsync();
}
我怎样才能让它出现一个“默认”的 Facebook 弹出对话框(你知道那些,例如 this one )从而让用户输入标题图像,而不是设置硬编码图像,就像我在上面的代码中那样。
parameters.putString("message", "my message for the page");
最佳答案
试试用下面的方法发消息
void PostFb()
{
Bundle parameters = new Bundle();
parameters.putString("name", getResources().getString(R.string.app_name));
parameters.putString("link", "http://www.youtube.com");//Put Image URL Here
facebook.dialog(this, "stream.publish", parameters,
new DialogListener() {
public void onFacebookError(FacebookError e) {
e.printStackTrace();
}
public void onError(DialogError e) {
// TODO Auto-generated method stub
e.printStackTrace();
}
public void onComplete(Bundle values) {
}
public void onCancel() {
}
});
}
让我知道它是否有效。因为它会显示您在此行输入的任何 url 的预览 parameters.putString("link", "http://www.youtube.com");
在这样做之前声明下面的参数
将上面这个类名声明为private Facebook facebook;
& 在onCreate
方法中这样初始化
facebook = new Facebook(APP_ID);
mAsyncRunner = new AsyncFacebookRunner(facebook);
关于android - 使用自定义消息将图像发布到 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20330013/