Facebook open graph
Facebook asks you to add "meta" code to your site.
I have created this module that allows you to enable this for your node types and their fields, automatically.
If you have set up a facebook app, this will be selectable in the settings for fb_meta.
Enable a contenttype and some of its fields, fill in the stuff fron the open graph fields, and you're ready to go.
It might need some tweaking or texts to change.
I dont now if this is something you want to include in your contrib folder...
The code is shared in a zip. Please let me know if you find this useful.
I called it fb_meta but maybe in the future it should be called fb_opengraph, since it opens your site up to the fb opengraph features.
Is this too crazy?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | opengraphprotocol_updated_2011.zip | 2.6 KB | tpainton |
| fb_meta.zip | 3.16 KB | wouters_f |
Comments
Comment #1
tpainton commentedI just got done looking over the new Open Graph docs on Facebook.. I am wanting to use my drupal site as server for the open graph objects. (see here https://developers.facebook.com/docs/opengraph/) All this really entails is wrapping the node fields and information in the correct Open Graph meta tags. So, using the example they do (on the link provided) it would seem Drupal would be perfect for hosting nodes that are 'recipes'. Users could then add content to the website, and also add content to the Open Graph as well. Pretty darn cool. It sounds like your module is attempting to do prepare pages with the metatags so drupal can do this.. I just downloaded your module.. going to take a look at it.. I think this is critical in making Drupal a backend for Facebook apps.
btw, my application is using Drupal with Services Module as a REST server for Android application. Drupal Stores the nodes which makes up the Open Graph Objects that users perform actions on. These nodes are subsequently swept into the Open Graph by Facebook using the Metatags that it looks like you have programmed to automagically wrap the data I want included in the Open Graph. Awesome.
Comment #2
tpainton commentedIt appears that fb_meta.admin.inc is missing. Can you please post it up, and I can do some testing. Thanks, that would be awesome.
Comment #3
tpainton commentedDue to a need for me to get this going.. I have started hacking away at my own version using bits of your code, plus some code from an independent project not found on Drupal.org called, Open Graph Protocol for Drupal.
I was/am really hoping to get a module out everyone could use but ran into a very big problem adding the prefix attribute to the head tag. Your code,
Appears to be jumbled, as if in mid edit.. I tried to code it out, but hook_preprocess_html doesn't seem to include the
<head>tag. Therefore, the critical prefix attribute in head isn't added and therefore the node technically shouldn't enter the Open Graph as an object. I ended up hard coding the prefix attribute into html.tpl.php.. TABOO!!! I know, but I can't find a way to add attributes to the head tag progmatically.Comment #4
Dave Cohen commentedThere's already modules/fb/fb_graph.module in the D6 branch. I just upgraded it and added it to the D7 branch, so it should be in the next .dev release. I feel bad it wasn't in there already as it might have saved some time.
Please look it over and tell me if its missing anything from your fb meta module that would make it better.
Comment #5
tpainton commentedOh no worries. I'm downloading now and seeing if it does a better job than what I hacked out. Thanks for the D7 upgrade!
Comment #6
wouters_f commentedThis is just awesome. Thank you
Comment #7
wouters_f commentedComment #8
Dave Cohen commentedCool. Changing to "fixed" makes this thread easier to find and will be promoted to closed automatically.
Comment #9
wouters_f commentedFor the others out there...
A list of drupal modules that do opengraph tags (f.e. for facebook):
To the maintainers of those modules: Join forces please :)
Comment #10
tpainton commentedThe problem with these other modules is that they don't apply all the information that Facebook asks for.. specifically the HEAD attribute..
At least from my perusal of the modules, I don't see this feature. Metatags specifically mentions that it doesn't add facebook specific tags and refers users to fb.module.
Comment #11
wouters_f commentedHow do you suggest to fix this?
In what module does this belong according to you?
Comment #12
tpainton commentedI can post my code for my current module that adds all the tags to a page according to the specific facebook requirements.. The problem is, I was unable to figure out how to add HEAD attribute as above. IF someone knows how to do that, then I would say they module could be included as a contrib.
I give full credit to the original author,
http://openspring.net/blog/2010/05/26/the-open-graph-protocol-and-drupal
I modified the code as it is two years old and doesn't seem to comply 100% with the current facebook requirements. (https://developers.facebook.com/docs/opengraph/)
It adds the tags as needed, but I admit, I have not yet tested it with my facebook app as I am not that far along yet. I am attaching the module..
NOTE, this module does not add the needed HEAD attribute....
I did a very UNDRUPAL thing and modified my HEAD attribute at core level.. It was the only way I could figure out how to do it.
Comment #13
Dave Cohen commentedI'm not familiar with the prefix attribute. I've never seen that before.
I think the right way to do it is either hook_rdf_namespaces() (D7) or modify your theme's template(s) (D6 or D7).
Comment #14
tpainton commentedThe link with the reference is here..
https://developers.facebook.com/docs/opengraph/tutorial/
Specifically, the paragraph,
"Remember to replace [YOUR_APP_NAMESPACE] and [YOUR_APP_ID] with your own app information."
Then the code example.
I did not try to accomplish a post to the graph without this because it seems like a lot of work to come up empty.
(edit) I just realized I'm repeating myself.. Sorry.. forgot what I wrote earlier.
Comment #15.0
(not verified) commentedcode included