3

我正在使用这段代码:

private void publishPhoto(String imageURL) {
    Log.d("FACEBOOK", "Post to Facebook!");

    try {

        JSONObject attachment = new JSONObject();
        attachment.put("message", Utils.s(R.string.fb_message));
        attachment.put("name", Utils.s(R.string.fb_name));
        attachment.put("href", Utils.s(R.string.url_dotzmag));
        attachment.put("description", Utils.s(R.string.fb_description));

        JSONObject media = new JSONObject();
        media.put("type", "image");
        media.put("src", imageURL);
        media.put("href", Utils.s(R.string.url_dotzmag));
        attachment.put("media", new JSONArray().put(media));

        JSONObject properties = new JSONObject();

        JSONObject prop1 = new JSONObject();
        prop1.put("text", "Dotz App on Android Market");
        prop1.put("href", Utils.s(R.string.url_android_market));
        properties.put("Get the App for free", prop1);

        JSONObject prop2 = new JSONObject();
        prop2.put("text", "Dotz Tuning on Facebook");
        prop2.put("href", Utils.s(R.string.url_facebook_fanpage));
        properties.put("Visit our fanpage", prop2);

        attachment.put("properties", properties);

        Log.d("FACEBOOK", attachment.toString());

        Bundle params = new Bundle();
        params.putString("attachment", attachment.toString());
        mFacebook.dialog(mActivity, "stream.publish", params, new PostPhotoDialogListener());
        //mAsyncRunner.request("me/feed", params, "POST", new WallPostRequestListener(), null);

    } catch (JSONException e) {
        Log.e("FACEBOOK", e.getLocalizedMessage(), e);
    }
}

public class PostPhotoDialogListener extends BaseDialogListener {

    public void onComplete(Bundle values) {
        final String postId = values.getString("post_id");
        if (postId != null) {
            Log.d("FACEBOOK", "Dialog Success! post_id=" + postId);
            Toast.makeText(mActivity, "Successfully shared on Facebook!", Toast.LENGTH_LONG).show();

        } else {
            Log.d("FACEBOOK", "No wall post made");
        }
    }
}

对话它工作正常,但我不想使用对话。所以我正在发送

res = facebook.request("feed", params, "POST");

像这样,因为我想支持单点登录和我的应用程序打开安装在用户设备中的 facebook 默认应用程序。如何摆脱这个错误。

4

0 回答 0