我尝试了不同的技术,但有些人只在 facebook 上共享图像,有些人只使用 SharePhoto 共享文本或带有 url 的文本,但没有人一次共享位图、描述和 url 等本地图像。可能是我做错了。我被困在一个一天如果有人知道的话,请给我一些详细的东西谢谢。
// App code
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(final JSONObject object, GraphResponse response) {
Log.v("LoginActivity", response.toString());
try {
if (isurl) {
ShareDialog shareDialog = new ShareDialog(mActivity);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://play.google.com/store?hl=en"))
.setContentDescription(message).setContentUrl(imgBitmapUri)
.build();
shareDialog.show(linkContent);
}
} else {
SharePhoto.Builder sharePhotoBuilder = new SharePhoto.Builder();
if (bitmap == null) {
sharePhotoBuilder.setBitmap(bitmap);
} else {
sharePhotoBuilder.setImageUrl(Uri.parse(imgBitmapPath));
}
sharePhotoBuilder.setUserGenerated(false);
final SharePhoto gesturePhoto = sharePhotoBuilder.build();
ShareOpenGraphObject shareOpenGraphObject = new ShareOpenGraphObject.Builder()
.putString("og:type", "favorite.share")
.putString("og:description", message)
.putPhotoArrayList("og:image", new ArrayList<SharePhoto>() {{
add(gesturePhoto);
}}).build();
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("favorite.share")
.putObject("favorite:share", shareOpenGraphObject)
.build();
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("favorite:share").setPreviewPropertyName("image")
.setAction(action)
.build();
ShareDialog.show(mActivity, content);
`enter code here` }
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,first_name, last_name, email,link");
request.setParameters(parameters);
request.executeAsync();