5

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?

2

1 Answer 1

5

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?

1
  • helped me... gosh this dumb "feature" of theirs is annoying to work with Oct 29, 2015 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.