picsoung
picsoung

Reputation: 6528

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!

Upvotes: 4

Views: 7908

Answers (2)

DMCS
DMCS

Reputation: 31880

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.

Upvotes: 7

ori
ori

Reputation: 7847

Add this to the head:

<script type="text/javascript">
    location = 'YOUR_HOME_PAGE';
</script>

Upvotes: 1

Related Questions