fb like links

3 posts by 3 authors in: Forums > CMS Builder
Last Post: September 27, 2012   (RSS)

By rez - September 26, 2012 - edited: September 27, 2012

I have used Facebook like buttons before and they have worked fine. Now, when using the like button code from here (XBFML):
http://developers.facebook.com/docs/reference/plugins/like/

This "likes" and posts fine to Facebook. But on Facebook when you click the link back to the site, FB now adds extra parameters to the end of the URL that are giving me "Record Not Found!" since it can't find the CMSB record.



// load records
list($projectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$projectsRecord = @$projectsRecords[0]; // get first record

// show error message if no matching record is found
if (!$projectsRecord) { dieWith404("Record not found!"); }



<fb:like href="http://www.domain.com<?php echo $projectsRecord['_link'] ?>" send="true" width="450" data-width="120" show_faces="false"></fb:like>



//should & used to give me
http://www.domain.com/project-details.php?myrecord-269


//but now gives me
http://www.domain.com/project-details.php?myrecord-269&fb_action_ids=290958784352169&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582


How can I deal with these parameters? I certainly don't want to have to set up an .htaccess file for this. ?

thanks.

Re: [rez] fb like links

By gkornbluth - September 27, 2012

Hi Rez,

Came across this:

function similar to rtrim only this will truncate the string at the 1st occurence of any character from $charlist
<?php

function rstrip($string, $charlist = "\t ") {
// removes everything from first occurence of char in charlist to end of string

$charlist = str_split($charlist);
$pos = strlen($string);

foreach ($charlist as $char) {
$pos = min(strpos($string, $char), $pos);
}

$string_stripped = substr($string, 0, $pos);

return $string_stripped;
}

?>


At this URL:

http://php.net/manual/en/function.rtrim.php


Hope it helps,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php