在墙上发布消息时,android facebook应用程序中出现错误代码3未知方法

在墙上发布消息时,android facebook应用程序中出现错误代码3未知方法,android,facebook,json,Android,Facebook,Json,您好,我正在尝试使用此代码在墙上发布消息 Bundle params = new Bundle(); params.putString(Facebook.TOKEN, facebook.getAccessToken()); params.putString("message", "Facebook Dialogs are easy!"); AsyncFacebookRunner mAsyn

您好,我正在尝试使用此代码在墙上发布消息

             Bundle params = new Bundle();
             params.putString(Facebook.TOKEN, facebook.getAccessToken());
             params.putString("message", "Facebook Dialogs are easy!");  
             AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
             mAsyncRunner.request(null, params, "POST", new SampleUploadListener(),null);
public class UpdateStatusResultDialog extends Dialog    {      private Bundle values;
private TextView mOutput, mUsefulTip;
private Button mViewPostButton, mDeletePostButton;
private Activity activity;
private Handler mHandler;

public UpdateStatusResultDialog(Activity activity, String title, Bundle values) {
    super(activity);
    this.activity = activity;
    this.values = values;
    setTitle(title);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE",
                    new WallPostDeleteListener(), null);
        }
    });
}

public class WallPostRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            JSONObject json = new JSONObject(response);
            setText(json.toString(2));
        } catch (JSONException e) {
            setText(activity.getString(R.string.exception) + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public class WallPostDeleteListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        if (response.equals("true")) {
            String message = "Wall Post deleted" + "\n";
            message += "Api Response: " + response;
            setText(message);
        } else {
            setText("wall post could not be deleted");
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public void setText(final String txt) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            mOutput.setText(txt);
        }
    });
}
但我得到了这个错误

Response: {"error_code":3,"error_msg":"Unknown method","request_args":[{"key":"message","value":"Facebook Dialogs are easy!"},{"key":"method","value":"POST"},{"key":"access_token","value":"AAAFby43GVwgBAJctMak5Y6IOaMylCWOFAXfXvsbMrckgZCi5wBZBSFWu02J1OY9ZB9aFLnwghHE72DgKe0YKIqctc5K54uyrA5mO5X2vQZDZD"},{"key":"format","value":"json"}]}
public class UpdateStatusResultDialog extends Dialog    {      private Bundle values;
private TextView mOutput, mUsefulTip;
private Button mViewPostButton, mDeletePostButton;
private Activity activity;
private Handler mHandler;

public UpdateStatusResultDialog(Activity activity, String title, Bundle values) {
    super(activity);
    this.activity = activity;
    this.values = values;
    setTitle(title);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE",
                    new WallPostDeleteListener(), null);
        }
    });
}

public class WallPostRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            JSONObject json = new JSONObject(response);
            setText(json.toString(2));
        } catch (JSONException e) {
            setText(activity.getString(R.string.exception) + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public class WallPostDeleteListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        if (response.equals("true")) {
            String message = "Wall Post deleted" + "\n";
            message += "Api Response: " + response;
            setText(message);
        } else {
            setText("wall post could not be deleted");
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public void setText(final String txt) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            mOutput.setText(txt);
        }
    });
}
谢谢兄弟,我试过了,但还是不行

             AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
             mAsyncRunner.request("Message Test", new SampleUploadListener());
public class UpdateStatusResultDialog extends Dialog    {      private Bundle values;
private TextView mOutput, mUsefulTip;
private Button mViewPostButton, mDeletePostButton;
private Activity activity;
private Handler mHandler;

public UpdateStatusResultDialog(Activity activity, String title, Bundle values) {
    super(activity);
    this.activity = activity;
    this.values = values;
    setTitle(title);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE",
                    new WallPostDeleteListener(), null);
        }
    });
}

public class WallPostRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            JSONObject json = new JSONObject(response);
            setText(json.toString(2));
        } catch (JSONException e) {
            setText(activity.getString(R.string.exception) + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public class WallPostDeleteListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        if (response.equals("true")) {
            String message = "Wall Post deleted" + "\n";
            message += "Api Response: " + response;
            setText(message);
        } else {
            setText("wall post could not be deleted");
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public void setText(final String txt) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            mOutput.setText(txt);
        }
    });
}
在这里我再次得到错误

public class UpdateStatusResultDialog extends Dialog    {      private Bundle values;
private TextView mOutput, mUsefulTip;
private Button mViewPostButton, mDeletePostButton;
private Activity activity;
private Handler mHandler;

public UpdateStatusResultDialog(Activity activity, String title, Bundle values) {
    super(activity);
    this.activity = activity;
    this.values = values;
    setTitle(title);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE",
                    new WallPostDeleteListener(), null);
        }
    });
}

public class WallPostRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            JSONObject json = new JSONObject(response);
            setText(json.toString(2));
        } catch (JSONException e) {
            setText(activity.getString(R.string.exception) + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public class WallPostDeleteListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        if (response.equals("true")) {
            String message = "Wall Post deleted" + "\n";
            message += "Api Response: " + response;
            setText(message);
        } else {
            setText("wall post could not be deleted");
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public void setText(final String txt) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            mOutput.setText(txt);
        }
    });
}
获取URL:Test?access_token=aaafby43gvwgbajctmak5y6ioamylcwofaxvsbmrckgzci5wbzbsfwu02j1oy9zb9aflnwghhe72dgke0ykiqctc5k54uyra5mo5x2vqzdzd&format=json 02-13 16:42:36.027:V/webview(13218):ZoomScale 3 mPreserveZoom:false 02-13 16:42:37.085:D/Facebook示例(13218):响应:400错误的RequestMethod未实现请求中的有效方法


02-13 16:42:37.085:W/Facebook示例(13218):JSON错误响应

参见以下编码

public class UpdateStatusResultDialog extends Dialog    {      private Bundle values;
private TextView mOutput, mUsefulTip;
private Button mViewPostButton, mDeletePostButton;
private Activity activity;
private Handler mHandler;

public UpdateStatusResultDialog(Activity activity, String title, Bundle values) {
    super(activity);
    this.activity = activity;
    this.values = values;
    setTitle(title);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE",
                    new WallPostDeleteListener(), null);
        }
    });
}

public class WallPostRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            JSONObject json = new JSONObject(response);
            setText(json.toString(2));
        } catch (JSONException e) {
            setText(activity.getString(R.string.exception) + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public class WallPostDeleteListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        if (response.equals("true")) {
            String message = "Wall Post deleted" + "\n";
            message += "Api Response: " + response;
            setText(message);
        } else {
            setText("wall post could not be deleted");
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public void setText(final String txt) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            mOutput.setText(txt);
        }
    });
}

}

嗨,兄弟……谢谢你的帮助……但还是有问题,我已经编辑了这个问题。去这个链接下载整个程序的Hackbook导入它,看到它包含所有功能链接上传图像或视频或更新状态等只是有一些错误,但评论他们。它会很好的工作,真是太棒了…希望我能在早上得到链接:(
public class UpdateStatusResultDialog extends Dialog    {      private Bundle values;
private TextView mOutput, mUsefulTip;
private Button mViewPostButton, mDeletePostButton;
private Activity activity;
private Handler mHandler;

public UpdateStatusResultDialog(Activity activity, String title, Bundle values) {
    super(activity);
    this.activity = activity;
    this.values = values;
    setTitle(title);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE",
                    new WallPostDeleteListener(), null);
        }
    });
}

public class WallPostRequestListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        try {
            JSONObject json = new JSONObject(response);
            setText(json.toString(2));
        } catch (JSONException e) {
            setText(activity.getString(R.string.exception) + e.getMessage());
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public class WallPostDeleteListener extends BaseRequestListener {

    @Override
    public void onComplete(final String response, final Object state) {
        if (response.equals("true")) {
            String message = "Wall Post deleted" + "\n";
            message += "Api Response: " + response;
            setText(message);
        } else {
            setText("wall post could not be deleted");
        }
    }

    public void onFacebookError(FacebookError error) {
        setText(activity.getString(R.string.facebook_error) + error.getMessage());
    }
}

public void setText(final String txt) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            mOutput.setText(txt);
        }
    });
}