[英]facebook post photo on the friends wall
我想在朋友墙上发贴,遇到困难。
首先,我将照片上传到我的墙上:
Request.Callback requestCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
if (response.getError() != null) {
Log.d("exception","error");
}
Object graphResponse = response.getGraphObject().getProperty("id");
if (graphResponse == null || !(graphResponse instanceof String)) {
Log.d("exception","not upload image");
} else {
String fbPhotoAddress = "https://www.facebook.com/photo.php?fbid=" +graphResponse;
Log.d("exception","fb="+fbPhotoAddress);
}
}
};
try {
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), image, requestCallback);
request.executeAsync();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
我不知道将如何使用此链接(fbPhotoAddress)。 我了解了Feed对话框,它以200x200px的尺寸拍摄照片。
我怎样才能做到这一点?
如果不需要使用facebook sdk,则可以使用如下代码:
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/png");
// gets the list of intents that can be loaded.
List<ResolveInfo> resInfo = activity.getPackageManager().queryIntentActivities(share, 0);
if (!resInfo.isEmpty()){
for (ResolveInfo info : resInfo) {
if (info.activityInfo.packageName.toLowerCase().contains("facebook") ||
info.activityInfo.name.toLowerCase().contains(type) ) {
share.putExtra(Intent.EXTRA_SUBJECT, subject);
share.putExtra(Intent.EXTRA_TEXT, text);
share.setPackage(info.activityInfo.packageName);
share.putExtra(Intent.EXTRA_STREAM, imageUri);
found = true;
break;
}
}
if (!found){
Toast.makeText(activity, type+" is not installed on the device", Toast.LENGTH_SHORT).show();
return;
}
activity.startActivity(Intent.createChooser(share, "Select"));
但是,如果您使用的是Facebook sdk,则可以使用如下所示的FacebookDialog,但是您需要与facebook集成,因此请阅读以下内容:
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(activity)
.setLink(link)
.setApplicationName(AppConstants.FACEBOOK_DISPLAY_APP_NAME)
.setPicture(pictureUrl)
.setName(subject)
//.setDescription(text)
.build();
您还需要问问自己自己,为什么要将这张照片添加到您的Facebook帐户,如果这样做是因为您没有照片的URL(本地照片),则无法使用Facebook URL进行工作,因为该URL是不公开的。 如果您对其进行测试,则会发现此URL将查看包含照片的Facebook页面,因此您需要将照片上传到任何服务器(例如AWS)上,然后使用照片URL进行共享。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.