Facebook Share/Like & URL Issue

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 7, 2013   (RSS)

Hi,

I've added fb like buttons across my website. When users like an article, fb generally adds a bunch of tags/parameters to the URL and when users click the link on facebook, they are given an error message: Record Not Found!

THis is how a shared/liked link looks like: http://www.illumemagazine.com/zine/articleDetail.php?The-Black-History-of-the-White-House-13745&fb_action_ids=4681431706510&fb_action_types=og.likes&fb_source=timeline_og&action_object_map=%7B%224681431706510%22%3A10150322600590421%7D&action_type_map=%7B%224681431706510%22%3A%22og.likes%22%7D&action_ref_map=[]

Is there a work around? Any suggestions?

Thanks!

Hi,

The best way to work around this is to change your code so that it uses a fixed variable in the URL, and not the last number in the URL. So you could change your URLS to look something like this:

 http://www.illumemagazine.com/zine/articleDetail.php?num=13745

or if you wanted to keep the SEO friendly url, you could use something like this:

 http://www.illumemagazine.com/zine/articleDetail.php?num=13745&The-Black-History-of-the-White-House-13745

Then if your using a getRecords function, you will need to change it so that it retrieves records based on the num value as opposed to the using the number at the end of the URL. Something like this should do the trick:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

$num = @intval($_REQUEST['num']);

// load record from 'blog'
list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'where' => $num,
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$blog = @$blogRecords[0]; // get first record
if (!$blog) { dieWith404("Record not found!"); } // show error message if no record found

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Ah. That makes sense. Thank you Greg.

I will update the code. But that would mean that all the social sharing tracking count will restart based on the new URLs... Let me see if there's a way to tweak the fb share code so the long string isn't added in the URL..

By Dave - March 7, 2013

Hi All, 

Just an update that this code is now in 2.52 beta 1 and will be in the official release.  

Thanks!

Dave Edis - Senior Developer
interactivetools.com