I am working on an game app contained in Facebook via the Canvas. The game consists of several order-independent 'levels' that each correlate to an entry in a database. Metaphorically, you can think of it as similar to hangman in that the game is the same each time but the content in different (in the case of hangman, that is the word being guessed).
When the user plays a level, I create a story via the OpenGraph API. So say for example Bob plays level Alpha, and his friend Sue sees his feed story which says "Bob played Alpha in SomeGame." I'd like a link in that story to take Sue directly to playing level "Alpha" in SomeGame, and not to the generic entry point in the game where the user can pick a level (i.e. what normally happens when you hit the Canvas URL). It appears that you can use params, like this:
apps.facebook.com/somegame?level_id=1234,
and then in your Canvas URL endpoint you can redirect based on those params. But is that the preferred way to handle this?
Also, if the story title in the Feed is "Bob played Alpha in SomeGame", I'd like the link on "Alpha" to take Sue to playing "Alpha", but as far as I can tell that link is generated by og:url in the object metadata, meaning it has to link to
www.somegame.com/level/:id, and not
apps.facebook.com/somegame?context_params=some_stuff.
But I really don't want people to visit
www.somegame.com/level/:id
directly - I'd like them to stay inside Facebook, and view it within the app hosted by Canvas.
I can get the behavior I want if I give
www.somegame.com/level/:id
a javascript redirect, which uses parameters for the level id:
(top.location.href="http://apps.facebook.com/somegame?level_id=1234)
However this seems like a hack, and I was hoping there is a cleaner way to do it, without a browser-driven redirect. Thanks!
Related
I have a website on which users can rate a concert and I'd like to post this action on the user's timeline.
But since facebook already has common Rate action only for books and videos, I cannot find a way to do this.
I see two alternatives (but I don't know if they're possible):
Using the common rate action on a custom object (for example, a music festival in my website)
Creating another action which is similar to rate just so I can publish on facebook (it is kind of cheating, but I can't really see another way)
I'd like to know which is the better way to go now, or if there's another alternative.
Since facebook only allows rating for books and videos yet, you could use in your facebook story symbols like ✪ or ✭.
So you only need to write them dynamically into your user story, user feed or the way you let your user post their ratings. I think when you put them into headline, they'll be big enough.
Here are some stars: ✩ ✪ ✫ ✬ ✭ ✮ ✯ ✰
I know that it is just a bad workaround, but as soon as I'll know that facebook changed their rating system, I'll update this answer.
Reading through the FB documentation I'm not sure how to approach this or if it is even possible with open graph.
I'm looking to create a story for a iOS app that will post an image taken by the user, along with title and description written by the user. This will deep link back into the app. Looking at the open graph documentation it looks like that is meant only for known and public accessible content. For example books read, movies watched, achievements earned for games etc.
Can I create user driven posts with open graph, or is it really the Graph API I should be looking at?
Main goal is too keep the content private and only viewable to those users the content has been shared with. Seems any open graph solution would make posts accessible by visiting a og: page with the right variables, no auth needed.
I don't totally understand everything you are asking (and I'm pretty new to all of this too) but here's a link on how to have a user post an image and message. You do need an auth though.
https://developers.facebook.com/docs/opengraph/howtos/adding-photos-to-stories/
I read through facebook's documentation and I've seen some examples on the webs, but I can't fully understand the process involved in posting content on the users timeline.
I want to connect the account of my users (users of a web application, which allows to manage and visualize some media content on a custom flash player) to Facebook, and whenever they want, let them share into their own timelines a "story" about the project they've just created.
In particular, I want to show on their timelines the flash player, and other HTML+CSS+JS content and/or interactions.
Something like "user has created a project on MyAPP" and then show a summary of that project on the timeline.
(I have already done something similar using only open graph meta tags and a URL that embeds a fully interactive flash player into the timeline, just like a youtube video)
I read through collections, actions, stories and other stuff, but I still don't know:
Is it possible to do this: share on behalve of the user, custom tailored content? Like custom HTML + CSS + JS (and Flash) ??
If the above is possible, what, nn general lines, must be done to accomplish it? Create a Facebook App, create custom actions, stories, collections, objects... ??
The picture bellow is what RunKeeper posts on my timeline after each of my runs. Is this graph something standard, made by Facebook? Or Runkeeper itself designs, creates and posts the content explicitly that way for their users ??
Is it possible to do this: share on behalve of the user, custom tailored content? Like custom HTML + CSS + JS (and Flash) ??
No, of course you can not embed custom HTML and CSS – since this would not be sandboxed by browsers, you could potentially alter the whole page (think about absolute/fixed positioning, etc.), way to dangerous to allow that.
Flash can be embedded in certain ways – either custom video players for objects of the video type, or previews of flash-based games in the feed (keyword: feed gaming).
The picture bellow is what RunKeeper posts on my timeline after each of my runs. Is this graph something standard, made by Facebook?
That is a story generated for the fitness.runs action and the fitness.unit object type. These are a common action and common object provided by Facebook, and they have the according story type layout pre-setup as well.
If the above is possible, what, nn general lines, must be done to accomplish it?
That question is too broad and general to be answered here. Read the Open Graph documentation, guides and how-tos more thoroughly – and then try stuff out and see what you get.
I successfully published a story from website via Feed and also another approach via sharer.php, but I want something different.
Downside of what I have now is that a picture is small and on the left side. There are no custom verbs as well.
I have seen something like (you can see a screenshot) a bigger photo and custom verbs like '%user got a new highscore at %site', etc.
Please look at a screenshot here
So I want to publish something similar what's shown on above picture. But with different text. 'Got a new highscore on'.
P.S. I want it to be done from website, where user has to log-in via Facebook.
I have defined "book" to be an open graph object in my Facebook app. A book is a logical unit, and the user can view a book in a number of different ways in the app. However, there is no single URL in my app which corresponds to any single book.
I thought I would be able to have a URL which spits out open graph meta data to Facebook behind the scenes. For example http://www.example.com/opengrpah/object_book.php?id=3265 would return the title, author, and other info for a book, but not actually be user visible.
However it appears that Facebook uses the object URL for actions involving the object. If I create an action related to the book (e.g. add a book), then if somebody clicks on the link in the ticker they will go to the object_book.php URL, instead of an actual app page. Thus they will see the meta data but nothing useful.
Is this by design? Certainly an object shouldn't have to correspond to a single user-visible page. Can we not have object data drawn from one URL, but have that object displayed to the user within the context of an app?
How about just redirecting from your Open Graph Object URL to the actual app page? Or how about designing your app pages to provide Open Graph metadata?
I think this could be a tricky solution.
In the app I'm working on we had a similar problem because it is an FB Canvas App, so if the og:url for our objects is something like http://apps.facebook.com/our_namespace/?my_first_obj=0 then FB sees the app itself instead of the object loaded in the app. That is where we ultimately want people to land, but we had to provide a direct URL to our app that provided the proper meta tags, much like your situation. I simply put this in the head of those pages:
<script>
try {
if (top.location.href === window.location.href) {
window.location.replace("http://apps.facebook.com/our_namespace/"+window.location.search);
}
} catch(e) {}
</script>
So if somebody is sent directly to that page, they are immediately redirected to our Canvas App, but Facebook's scraper can still get the correct meta data about the object.
I had a similar problem and I ended up with 2 layers for my objects. One is the "master" object, which is actually the object (book in your case, goal in mine).
Then, I have another "user" object, which is actually an association between the master object and a user. This user object has the url like mysite/user/object and it's what I publish to the fb graph with the "add" action.