When creating a new node, and using FB stream to post to a page (and I'm assuming user) wall/feed, facebook does not see the open graph tags associated with the node. This is because hook_node_insert runs before the node is completely saved, and therefor, facebook attempts to scan the page for open graph tags before the page technically exists. This can be worked around by not posting anything on first node creation, and then editing the node and posting on the edit, as the page already exists and the tags are there. If you do attempt to post on the node creation, facebook will get only the values that were passed with the post api (link, title, body) and then cache the empty link, so even if you edit after that and attempt to post again, because facebook already cached the page before it was technically there the open graph tags still don't show up. To work around this, you can use the facebook debugger / linter to re-cache the page, and then re edit the node and post again. At this point, the open graph image tags and all other open graph tags will be picked up by facebook and embedded into the post.

I spent some time trying to find a node_postsave hook, but without chopping up core I could not find one, but then I found:
drupal_register_shutdown_function

which calls a function after the node is saved and drupal is shutting down. I am creating this post so I can have an issue # for the patch I created. I will be posting the patch as a reply to this page shortly.

Please keep in mind that this is my first "real" patch and it's probably not perfect by any means, but my hope is if there are mistakes the community can expand upon them.

Comments

Gode.Agarunov’s picture

Status: Active » Needs review
StatusFileSize
new839 bytes

*** Disregard this post and patch ***

Gode.Agarunov’s picture

StatusFileSize
new839 bytes

Came to check thread for responses and realized that my patch doesn't work, because I put the # sign into it. Sorry. Attached is a patch that can actually be downloaded, and if anyone knows a way to delete or edit out the download in my prior post please let me know, as when I press edit the download does not seem to be there at all.

** edit (I removed this from previous post, and added it here): Keep In mind, you have to use a module or something to create the open graph tags to make this work. Either the open graph module that comes with drupal for facebook, open graph meta tags, the meta tags open graph module, or anything else that puts open graph stuff in meta tags. **

dinotav’s picture

I had the same problem and with your first patch works fine now!

thks

Dave Cohen’s picture

Assigned: Unassigned » Dave Cohen
Status: Needs review » Reviewed & tested by the community

How did I not know sooner about drupal_register_shutdown_function?

Thanks I'll get this in.

Dave Cohen’s picture

Status: Reviewed & tested by the community » Fixed

pushed. Thanks again.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.