Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query strip is removed from open graph url

In relation to this question: Dynamic generation of Facebook Open Graph meta tags

I have followed these instructions but the api seems to remove my query string so that the url passed into the aggregation contains none of my dynamic information. If I enter the url with the query string into the debugger it doesn't remove it and works fine. I can confirm my og:url meta tag does also contain the same query string not just the base url. What am I doing wrong?

like image 761
Baxter Avatar asked Jan 09 '12 15:01

Baxter


People also ask

What is Open Graph URL?

Open Graph meta tags are snippets of code that control how URLs are displayed when shared on social media. They're part of Facebook's Open Graph protocol and are also used by other social media sites, including LinkedIn and Twitter (if Twitter Cards are absent). You can find them in the <head> section of a webpage.

What is Open Graph tags in SEO?

Open Graph Meta Tags are snippets of text that are used to communicate a page's content with social media (such as Facebook and Twitter). It allows integration of your site and Facebook and tells what content shows up when you share a page on Facebook.

What is OG Site_name?

og:site_name : The name of the overall website your content is on. If you're on a blog post page, you might have a title using that blog post's title, where the site_name would be the name of your blog.


1 Answers

I was having a similar issue and solved it like this:

So assuming you're doing your post request like it shows in the tutorial, youre Javascript probably looks something like this:

  function postNewAction()
  {
      passString = '&object=http://yoursite.com/appnamespace/object.php';

      FB.api('/me/APP_NAMESPACE:ACTION' + passString,'post',
         function(response) {
              if (!response || response.error) {
                  alert(response.error.message);
              } 
              else {
                  alert('Post was successful! Action ID: ' + response.id);
              } 
          }
      );    
  }

And since you say you want to generate meta tags dynamically, you're probably adding a parameter to the url (passString) there like so:

  passString = '&object=http://yoursite.com/appnamespace/object.php?user=' + someuser;

This is wrong.

What you need to do is to make the url a 'pretty url' and use htaccess to decipher it. So:

  passString = '&object=http://yoursite.com/appnamespace/object/someuser';

Then your htaccess file will tell your site that that url actually equates to

  http://yoursite.com/appnamespace/object/object.php?user=someuser

Then you can use GET to store the user parameter with php and insert it however you like into your meta tags.

In case youre wondering, in the og:url meta tag's content will be:

  $url = 'http://yoursite.com/appnamespace/object/object.php?user=' . $_GET[$user];

Does that help?

like image 144
bradleygriffith Avatar answered Oct 18 '22 13:10

bradleygriffith