Android 自动发布到facebook墙

Android 自动发布到facebook墙,android,facebook,Android,Facebook,我的代码如下:- public void publishFeedDialog(final Activity activity, final FacebookLogin fl) { Session session = Session.getActiveSession(); //if session is not empty and it is opened if (session != null && session.isOpened()){

我的代码如下:-

public void publishFeedDialog(final Activity activity, final FacebookLogin fl) 
{
    Session session = Session.getActiveSession();

    //if session is not empty and it is opened
    if (session != null && session.isOpened()){

        // Check for publish permissions    
        List<String> permissions = session.getPermissions();
        if (!isSubsetOf(PERMISSIONS, permissions)) {
            pendingPublishReauthorization = true;
            Session.NewPermissionsRequest newPermissionsRequest = new Session
                    .NewPermissionsRequest(activity, PERMISSIONS);
            session.requestNewPublishPermissions(newPermissionsRequest);
            return;
        }
            Bundle params = new Bundle();

            params.putString("name", "test");
            params.putString("message", "MESSAGE TO GO WITH THE IMAGE");
            params.putString("description", "test test test");

        WebDialog feedDialog = (
                new WebDialog.FeedDialogBuilder(activity,
                        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) {

                                        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                                        builder.setTitle("POST")
                                        .setMessage("")
                                        .setCancelable(false)
                                        .setNegativeButton("OK",
                                                new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog, int id) {
                                                dialog.cancel();
                                            }
                                        });
                                        AlertDialog alert = builder.create();
                                        alert.show();
                                    } else {
                                        // User clicked the Cancel button
                                        Toast.makeText(activity, 
                                                "Publish cancelled", 
                                                Toast.LENGTH_SHORT).show();
                                    }
                                } else if (error instanceof FacebookOperationCanceledException) {
                                    // User clicked the "x" button
                                    Toast.makeText(activity, 
                                            "Publish cancelled", 
                                            Toast.LENGTH_SHORT).show();
                                } else {
                                    // Generic, ex: network error
                                    Toast.makeText(activity, 
                                            "Error posting story", 
                                            Toast.LENGTH_SHORT).show();
                                }
                            }

                        })
                        .build();
        feedDialog.show();
    }
    else
    {
        // login with facebook if no session is available

    }
}   
public void publishFeedDialog(最终活动活动,最终facebook登录fl)
{
Session=Session.getActiveSession();
//如果会话不为空且已打开
if(session!=null&&session.isOpened()){
//检查发布权限
List permissions=session.getPermissions();
如果(!isSubsetOf(权限、权限)){
pendingPublishReauthorization=真;
Session.newpermissions请求newpermissions请求=新会话
.newpermissions请求(活动、权限);
session.requestNewPublishPermissions(newPermissionsRequest);
返回;
}
Bundle params=新Bundle();
参数putString(“名称”、“测试”);
参数putString(“消息”,“与图像相关的消息”);
参数putString(“说明”、“测试”);
WebDialog feedDialog=(
新建WebDialog.FeedDialogBuilder(活动,
Session.getActiveSession(),
参数)
.setOnCompleteListener(新的OnCompleteListener(){
@凌驾
未完成的公共void(束值,
FacebookException错误){
如果(错误==null){
//当故事发布时,回应成功
//还有邮政Id。
最终字符串postId=values.getString(“post_id”);
如果(postId!=null){
AlertDialog.Builder=新建AlertDialog.Builder(活动);
建造商名称(“职位”)
.setMessage(“”)
.setCancelable(错误)
.setNegativeButton(“确定”,
新建DialogInterface.OnClickListener(){
public void onClick(DialogInterface对话框,int-id){
dialog.cancel();
}
});
AlertDialog alert=builder.create();
alert.show();
}否则{
//用户单击了“取消”按钮
Toast.makeText(活动,
“已取消发布”,
吐司。长度(短)。show();
}
}else if(FacebookOperationCanceledException的错误实例){
//用户单击“x”按钮
Toast.makeText(活动,
“已取消发布”,
吐司。长度(短)。show();
}否则{
//通用,例如:网络错误
Toast.makeText(活动,
“发布故事时出错”,
吐司。长度(短)。show();
}
}
})
.build();
feedDialog.show();
}
其他的
{
//如果没有可用会话,请登录facebook
}
}   
我试图将文字信息/描述发送到facebook帖子,但失败了。我也有问题自动分享。目前我只需要点击post按钮就可以将内容发布到我的facebook上。任何帮助都将不胜感激


感谢高级课程。

使用以下内容,它对您的社会融合有很大帮助。

提要对话框不支持“消息”字段

请参见此处的提要对话框文档: