显示多张图片,并允许用户使用选择在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.");
}
}
}
答案 0 :(得分:0)
您使用什么SDK访问Facebook?
您应该使用Facebook directly(或其他包含它的人)提供的最新SDK(3.0),并使用其会话管理和请求类。
在您的情况下,如果您要发布到用户的墙上,可以使用Request.newPhotoUploadRequest方法,该方法采用位图。正如其他人已经提到的那样,你不能再发布到朋友的墙上了。