-
Notifications
You must be signed in to change notification settings - Fork 349
Publish story
This doc is about to be udated till Dec 1st
. All described below is great, but code supports much greater stuff (like dialog). Be updated.
It is possible to create and share open graph stories. Story consists of two main parts:
-
StoryObject
- The object that you want to appear on the wall. -
StoryAction
- The action that relates to the object.
For example: Eat food is the definition for many possible food objects that can be eaten. Like:
- Eat apple
- Eat honey
- Eat steak,
- ...
- Define new custom story in your app dashboard on facebook.
- Upload object meta tags that describe your noun (object) on your server or create one on facebook servers.
- Publish the story.
-
Defined story:
± Create new object called:
Food
and add new custom property calledcalories
of int type.
± Create new action calledEat
and add new custom property calledtaste
of string type.
± Edit the output of the story including the custom values. -
Upload object:
Two options are possible:
- Use
create(StoryObject, OnCreateStoryObject)
- to create objects and upload them to facebook servers - Upload story meta tags to your private servers.
I used the option 2. Create these html page and upload to your server:
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# sromkuapp_vtwo: http://ogp.me/ns/fb/sromkuapp_vtwo#"> <meta property="fb:app_id" content="728615400528729" /> <meta property="og:type" content="sromkuapp_vtwo:food" /> <meta property="og:url" content="http://romkuapps.com/github/simple-facebook/object-apple.html" /> <meta property="og:title" content="Apple" /> <meta property="og:image" content="http://romkuapps.com/github/simple-facebook/apple.jpg" /> <meta property="og:description" content="The apple is the pomaceous fruit of the apple tree, Malus domestica of the rose family. It is one of the most widely cultivated tree fruits." /> <meta property="sromkuapp_vtwo:calories" content="52" />
I uploaded it to:
http://romkuapps.com/github/simple-facebook/object-apple.html
- Use
-
Publish the story:
Initialize callback listener:
OnPublishListener onPublishListener = new OnPublishListener() { @Override public void onComplete(String id) { Log.i(TAG, "Published successfully. id = " + id); } /* * You can override other methods here: * onThinking(), onFail(String reason), onException(Throwable throwable) */ };
Build story for publishing:
// set object to be shared StoryObject storyObject = new StoryObject.Builder() .setUrl("http://romkuapps.com/github/simple-facebook/object-apple.html") .setNoun("food") .build(); // set action to be done StoryAction storyAction = new StoryAction.Builder() .setAction("eat") .addProperty("taste", "sweet") .build(); // build story Story story = new Story.Builder() .setObject(storyObject) .setAction(storyAction) .build(); // publish mSimpleFacebook.publish(story, onPublishListener);
The result:
-
Setup
-
Login/Logout
-
Publish 🔻
-
Requests/Invite
-
Get
-
Additional options
-
Samples