Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGraph - choose where og:url points / redirect user and keep tags working

I am trying to implement OpenGraph actions and object. It works fine, I am able to create objects and actions in the ticker/Timelime.

My only concern is when you display the object, its title is a link. But it links to the page I use to generate the object, so there is nothing to display :

object.html.erb

<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# name_space: http://ogp.me/ns/fb/name_space#">
<meta property="fb:app_id"        content="APP_ID" /> 
<meta property="og:type"          content="name_space:object" /> 
<meta property="og:url"          content="PATH_TO_METHOD_TO_CREATE_OBJECT?img_link=<%= CGI.escape(@img_link)%>&points=<%=@points%>&description=<%= @description%>" /> 
<meta property="og:title"         content="<%= params[:units_offered] %> Points" /> 
<meta property="og:description"   content="<%= params[:description] %>" />
<meta property="og:image"       content="<%= params[:img_link] %>">

if I change the og:url meta tag to the url of my FB page then the object picks my FB page value..

in a perfect I wanted to link to nothing or my FB page.

Any clue ?

Thanks!

like image 751
Nicolas Grenié Avatar asked Feb 22 '23 09:02

Nicolas Grenié


1 Answers

Since the linter doesn't run javascript, you can do a javascript redirection for the user to go to the place you want.

<script> location.href = 'http://example.com/the_real_page.php'; </script>

This way the linter can still see the correct og meta tags, and the user who clicks the link gets redirected to the correct location.

like image 75
DMCS Avatar answered May 15 '23 16:05

DMCS