如何在 Android 中创建和使用自托管对象来共享自定义故事? [英] How to create and use self hosted objects to share custom stories in Android?
问题描述
我正在开发一款游戏应用.我正在我的应用程序中分享 facebook 自定义故事.我创建了一个自托管对象(html 页面).
I am developing a game app. And I am sharing facebook custom stories in my app.I have created a self hosted object(html page).
我想在 android、ios 和 Facebook 画布应用程序中使用相同的自托管对象.我已经完成了自定义故事共享,而没有为 android 应用程序使用自托管对象,下面是我的代码
I want to use that same self hosted object in android,ios and Facebook canvas app. I have already done custom story sharing without using self hosted object for android app and below is my code for the same
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
是我的对象.
where unlock
is my action and level
is my object.
但我希望它使用我创建的自托管对象,以便我可以在所有平台(Android、IOS、Web)上使用相同的对象.
But I want it to do using self hosted object that I have created so that I can use same object for all platforms (Android, IOS , Web).
在文档中提到自托管对象对于多平台应用程序比使用对象 api 更有用.我跟着这个 https://developers.facebook.com/docs/opengraph/using-objects/#selfhosted 文档,但无法在任何地方找到如何在 Android 上使用它.
In documentation it is mentioned that Self-Hosted Objects are more useful for multi platform app than using Object api. I followed this https://developers.facebook.com/docs/opengraph/using-objects/#selfhosted document but couldn't found anywhere there how to use it on Android.
我用于创建自托管对象(html 页面)的代码
My code for creating an self hosted object (html page)
<!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 中使用自托管对象,我的工作代码会有什么变化,或者我必须以另一种方式来做?
If I want to use self hosted object in my Android what will be the changes in my working code or I have to do it in another way ?
任何建议将不胜感激,在此先感谢您.
Any suggestion will be highly appreciated, Thank you in advance.
推荐答案
最后我解决了,其实文档本身就有方法,但是那里没有特别提到这段代码将用于自托管对象.
Finally I solved it , actually method was there in the document itself , but it wasn't specifically mentioned there that this code will be used for self hosted object.
下面是我的代码:
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 中创建和使用自托管对象来共享自定义故事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!