1

显示多张图片并允许用户使用选择将其中一张张贴到 Facebook Friend's Wall 上。

我仍然允许用户将静态图像发布到 Facebook Wall,但现在我想允许用户从多个图像中选择一个图像,然后发布到墙上。

我正在使用以下代码将特定图像发布到墙上,使用此代码:

params.putString("picture", FacebookUtility.STATIC_IMAGE_URL); 

发布静态图像的代码

  public void onItemClick(AdapterView<?> adapterView, View view,
        int position, long id) {
            try {
            final long friendId;
            friendId = jsonArray.getJSONObject(position).getLong("uid");
            String name = jsonArray.getJSONObject(position).getString("name");
            new AlertDialog.Builder(this)
                    .setTitle(R.string.post_on_wall_title)
                    .setMessage(
                            String.format(getString(R.string.post_on_wall),
                                    name))
                    .setPositiveButton(R.string.yes,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog,
                                        int which) {
                                    Bundle params = new Bundle();

                                    params.putString("to",
                                            String.valueOf(friendId));
                                    params.putString("caption",
                                            getString(R.string.app_name));
                                    params.putString("description",
                                            getString(R.string.app_desc));
                                    params.putString("link", 
                                            "http://www.google.com");
                                    params.putString("picture", 
                                            FacebookUtility.STATIC_IMAGE_URL);                          
                                    params.putString("name",
                                            getString(R.string.app_action));
                                    FacebookUtility.facebook
                                            .dialog(FriendsList.this,
                                                    "feed",
                                                    params,
                                                    (DialogListener) new PostDialogListener());
                                }

                            }).setNegativeButton(R.string.no, null).show();
        } catch (JSONException e) {
            showToast("Error: " + e.getMessage());
        }
    }

    public class PostDialogListener extends BaseDialogListener {
        @Override
        public void onComplete(Bundle values) {
            final String postId = values.getString("post_id");
            if (postId != null) {
                showToast("Message posted on the wall.");
            } else {
                showToast("No message posted on the wall.");
            }
        }
    }
4

1 回答 1

0

您使用什么 SDK 访问 Facebook?

您应该直接使用 Facebook提供的最新 SDK (3.0) (或其他包含它的 SDK),并使用其 Session 管理和 Request 类。

在你的情况下,如果你想发布到用户的墙上,你可以使用Request.newPhotoUploadRequest方法,它需要一个位图。正如其他人已经提到的那样,您不能再发布到朋友的墙上了。

于 2013-03-28T15:53:06.373 回答