TanC
TanC

Reputation: 153

laravel application can only share index page to facebook

I have an application on laravel and i am using AddThis (https://www.addthis.com/) for my website.

Everything is fine when i try to share the homepage, but i keep getting this "Whoops! There was an error." when i try to share any non-index pages.

I am using templating for the mata-data on the various pages

in my base.blade.php i have

<meta property="og:site_name" content="ALLMENZ" />
<meta property="og:url" content="mycontent" />
<meta property="fb:app_id" content="" />    <!-- for facebook-insights-->

<meta property="og:title" content="{{{$meta_title}}}" />
<meta property="og:description" content="{{{$meta_description}}}" />
<meta property="og:image" content="{{{$meta_photo}}}" />

and in the non-index page i have

<?php View::share('meta_title', 'user timeline'); ?>
<?php View::share('meta_description', 'this is the user timeline page'); ?>
<?php View::share('meta_photo', ''); ?>

Anyone has any idea what is happening here? Thanks in advance (=

Upvotes: 0

Views: 2510

Answers (2)

Israel  Kloss
Israel Kloss

Reputation: 51

What Worked For Me

If you happen to be trying to use AddThis with UTM codes or other querystring variables, here's what finally worked for me.

As per Sol, use OpenGraph meta tags but then use the FB Debugger to verify that Facebook cache has been refreshed and got all the proper meta tags in the page header correctly, then verify that there are no querystring UTMs/variables your AddThis sharing link to facebook. For my purposes, Index.html couldn't include any querystring variables or AddThis passed the URL incorrectly to Facebook. The only way that worked for me looks like this:

<a href="http://api.addthis.com/oexchange/0.8/forward/facebook/offer?pco=tbx32nj-1.0&amp;url=https%3A%2F%2Fwww.example.com%2Findex.html" target="_blank" ><img src="http://cache.addthiscdn.com/icons/v1/thumbs/32x32/facebook.png" border="0" alt="Facebook" /></a>

What Failed For Me

When trying to use the below AddThis "data_track_addressbar" and "addthis_widget.js" modules for sharing, Facebook completely fail to pull the new OpenGraph Meta Tags.

<script type="text/javascript">var addthis_config = {"data_track_addressbar":false};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script>

Upvotes: 0

The Alpha
The Alpha

Reputation: 146239

You should generate the tag's content dynamically, for example, to generate the current url with http/https use following in your og:url:

<meta property="og:url" content="{{ Request::url() }}" />

The Request::url() will generate the current url for the page you are on. Also, don't leave any blank content in any meta tag. Then debug the url's using Debugger Tool.

Upvotes: 2

Related Questions