开发者

Facebook SDK and Android - Feed post succeeds with error

开发者 https://www.devze.com 2023-02-14 00:10 出处:网络
I\'m doing a feed post through Facebook SDK on Android. It was working just fine before, but since I changed my FB App ID, the post works but the SDK throws a null FacebookError exception. Tracing a

I'm doing a feed post through Facebook SDK on Android.

It was working just fine before, but since I changed my FB App ID, the post works but the SDK throws a null FacebookError exception. Tracing a little more, I can see that the FB request returns false, even though it correctly completes the post!

If I use the former App_id, it works without a hitch. But if I use new App_id, then I get this error, which means it has nothing to do with the code, but most likely an app setting. However, I don't know what that setting is.

Just in case, here is the code. It is pretty much straight out of the example:

private class SampleDialogListener extends FBBaseDialogListener {

    public void onComplete(Bundle values) {
        final String postId = values.getString("post_id");
        if (postId != null) {
            //POST ID is valid here
            _app.Fb.getAsynchRunner().request(postId, new WallPostRequestListener());
        } else {
            ShowChallenge.this.runOnUiThread(new Runnable() {
                public void run() {
                    String errorMsg = getResources().getString(R.string.errorUnableToPostFeedOnFacebook);
                    Toast.makeText(ShowChallenge.this, errorMsg, Toast.LENGTH_SHORT).show();
                }
            });
        }
    }
}

public class WallPostRequestListener extends FBBaseRequestListener {

    public void onComplete(final String response, final Object state) {
        //Log.d("Facebook-Example", "Got response: " + response);
        boolean fbPostSuccess = false;
        try {
            //response is 'false'
            JSONObject json = Util.parseJson(response); //throws FacebookError exception
            fbPostSuccess = true;
        } catch (JSONException e) {
            Log.w("Facebook-Example", "JSON Error in response");
        } catch (FacebookError e) {
            //EXCEPTION HERE!
            //Log.w("Facebook-Example", "Facebook Error: " + e.getMessage());
        }
        //Former APP ID succeeds without a hitch. What could it b开发者_开发知识库e?
        final String msg = getResources().getString(fbPostSuccess ? R.string.facebookPostSucessful : R.string.errorUnableToPostOnFacebookWall);
        ShowChallenge.this.runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(ShowChallenge.this, msg, Toast.LENGTH_SHORT).show();
            }
        });
    }
}

0

精彩评论

暂无评论...
验证码 换一张
取 消