从 Android 应用向 Facebook 发布开放图谱常见操作(收听)时无预览
No Preview When Publishing a Open Graph Common Action (Listen) to Facebook from an Android App
尝试在 Facebook 中创建自定义故事失败后(参见 here)
我决定使用 Facebook 的 "Listen" Open Graph 常用操作 pre-defined。这是我的代码:
// Facebook
mImageButtonShareOnFacebook = (ImageButton)view.findViewById(R.id.shareOnFacebook);
mImageButtonShareOnFacebook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(_albumCover)
.setUserGenerated(true)
.build();
// Create an object
String fbAppId = getActivity().getString(R.string.facebook_app_id);
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("fb:app_id", fbAppId)
.putString("og:type", "music.song")
.putString("og:title", _title + " by " + _artist + " in XYZ Radio " + channel.getName() + " channel")
.putString("og:site_name", "XYZ Radio")
.putPhoto("og:image", photo)
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("music.listens")
.putObject("song", object)
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("song")
.setAction(action)
.build();
ShareDialog.show(NowPlayingFragment.this, content);
}
});
这就是我得到的:
不过,已发布的 post 似乎是正确的。
那么,为什么我会收到 "A preview will be added after you post this link to..." 消息?这是默认行为还是我错过了什么?提前致谢...
我相信这是设计使然,阅读更多关于 pre-caching here:
When content is shared for the first time, the Facebook crawler will
scrape and cache the metadata from the URL shared. The crawler has to
see an image at least once before it can be rendered. This means that
the first person who shares a piece of content won't see a rendered
image.
我相信类似的概念适用于 OG 预览。
尝试在 Facebook 中创建自定义故事失败后(参见 here)
我决定使用 Facebook 的 "Listen" Open Graph 常用操作 pre-defined。这是我的代码:
// Facebook
mImageButtonShareOnFacebook = (ImageButton)view.findViewById(R.id.shareOnFacebook);
mImageButtonShareOnFacebook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(_albumCover)
.setUserGenerated(true)
.build();
// Create an object
String fbAppId = getActivity().getString(R.string.facebook_app_id);
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("fb:app_id", fbAppId)
.putString("og:type", "music.song")
.putString("og:title", _title + " by " + _artist + " in XYZ Radio " + channel.getName() + " channel")
.putString("og:site_name", "XYZ Radio")
.putPhoto("og:image", photo)
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("music.listens")
.putObject("song", object)
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("song")
.setAction(action)
.build();
ShareDialog.show(NowPlayingFragment.this, content);
}
});
这就是我得到的:
不过,已发布的 post 似乎是正确的。
那么,为什么我会收到 "A preview will be added after you post this link to..." 消息?这是默认行为还是我错过了什么?提前致谢...
我相信这是设计使然,阅读更多关于 pre-caching here:
When content is shared for the first time, the Facebook crawler will scrape and cache the metadata from the URL shared. The crawler has to see an image at least once before it can be rendered. This means that the first person who shares a piece of content won't see a rendered image.
我相信类似的概念适用于 OG 预览。