我正在开发一款游戏应用。我正在我的应用程序中分享 Facebook 自定义故事。我创建了一个自托管对象(html 页面)。
我想在 android、ios 和 Facebook canvas 应用程序中使用相同的自托管对象。 我已经在不使用 Android 应用程序的自托管对象的情况下完成了自定义故事共享,下面是我的相同代码
OpenGraphObject objProperty = OpenGraphObject.Factory.createForPost("namespace:level");
objProperty.setProperty("title","Title");
objProperty.setProperty("image","http://www.example.com/jokedemo/image/wrong.jpg");
objProperty.setProperty("url", "http://www.example.com");
objProperty.setProperty("description", "Can you beat me?");
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("level", objProperty);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(FBActivity.this, action,"namespace:unlock", "level").build();
unlock
是我的操作,level
是我的对象。
但我希望它使用我创建的自托管对象,以便我可以为所有平台(Android、IOS、Web)使用相同的对象。
在文档中提到自托管对象对于多平台应用程序比使用对象 api 更有用。 我跟着这个https://developers.facebook.com/docs/opengraph/using-objects/#selfhosted文档,但无法在任何地方找到如何在 Android 上使用它。
我创建自托管对象的代码(html 页面)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta property="fb:app_id" content="*************" />
<meta property="og:type" content="namespace:level" />
<meta property="og:title" content="Title" />
<meta property="og:url" content="https://example.com/namespace/level.html" />
<meta property="og:description" content="Can you beat me?" />
<meta property="og:image" content="https://example.com/namespace/image/abc.png" />
</head>
<body>
</body>
</html>
如果我想在我的 Android 中使用自托管对象,我的工作代码会发生什么变化,或者我必须以其他方式来做?
任何建议将不胜感激,提前致谢。
最佳答案
最后我解决了它,实际上方法在文档本身中,但是没有特别提到这段代码将用于自托管对象。
下面是我的代码:
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("level","https://example.com/namespace/level.html"); //here "level" is the Object name and url is the self hosted object
action.setType("namespace:unlock"); //"unlock" is the Action name
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(FBActivity.this, action, "level").build();
关于android - 如何创建和使用自托管对象在 Android 中共享自定义故事?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23995978/