我尝试使用Facebook SDK中的ShareDialog分享链接(我的Google Play应用链接),但问题是当网址是我的应用的Google Play链接时,其他信息无法正确显示...实际上它只显示来自Google Play的链接,没有名称或描述!
以下是代码:
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(
this)
.setLink("https://play.google.com/store/apps/details?id=<myapp>")
.setDescription("Test")
.setName("Test for facebook")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
我尝试了所有内容,并且其他网址实际上正在运行(显示姓名,说明,标题等),但没有使用该应用的网址。
有谁知道为什么Google Play链接无法使用文字,说明或字幕?
答案 0 :(得分:4)
实际上,如果您指定contentUrl
(如4.0中)或link
(如您的情况),则会覆盖name
,description
等。您只需不需要提供其他内容,因为 url host 负责提供在Facebook时间线上发布时应显示的详细信息。
但是,如果您要分享Message from user
之后的app link
。然后我建议去图谱API (我通过ShareApi / ShareDialog发布这样的东西浪费了2-3天,但结果只使用了图谱API。)
使用Graph API分享的代码:
// Constants to be used when sharing message on facebook time line.
private static final int FACEBOOK_ERROR_PERMISSION = 200;
private static final String PARAM_EXPLICIT = "fb:explicitly_shared";
private static final String PARAM_GRAPH_PATH = "/me/feed";
private static final String PARAM_MSG = "message";
private static final String PARAM_LINK = "link";
// Create the parameter for share.
final Bundle params = new Bundle();
params.putBoolean(PARAM_EXPLICIT, true);
params.putString(PARAM_LINK, BirdingUtah.APP_URL);
// If message is empty, only our link gets posted.
String message = "This is the message to share";
if (!TextUtils.isEmpty(message))
params.putString(PARAM_MSG, message);
// Send the request via Graph API of facebook to post message on time line.
new GraphRequest(AccessToken.getCurrentAccessToken(), PARAM_GRAPH_PATH,
params, HttpMethod.POST, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
searchDialog.dismiss();
if (graphResponse.getError() == null) {
// Success in posting on time line.
Logger.toastShort(R.string.msg_share_success);
Logger.debug(TAG, "Success: " + graphResponse);
} else {
FacebookRequestError error = graphResponse.getError();
if (error.getErrorCode() == FACEBOOK_ERROR_PERMISSION)
// Cancelled while asking permission, show msg
Logger.toastLong(R.string.msg_share_permission);
else
// Error occurred while posting message.
Logger.toastShort(R.string.msg_share_error);
Logger.error(TAG, "Error: " + error);
}
// Enable the button back again if profile and access token are non null.
if (Profile.getCurrentProfile() != null || AccessToken.getCurrentAccessToken() != null)
mShareButton.setEnabled(true);
}
}).executeAsync();