Hello everyone!

I am utilizing the aggregator module for Drupal 6.17 to display the RSS feeds of a Facebook wall in a block that I have located in the sidebar. Everything looks great except for links to the Facebook wall posts. For some reason rather than linking to http://www.facebook.com/permalink.php?story_fbid=.. etc, it's linking to my site: http://www.mysite.com/permalinkphp?story.. etc. However, if the RSS links to the photo album in Facebook, it appears correctly e.g.: http://www.facebook.com/album.php?aid=.....

Any help would be appreciated from this newbie!

Comments

Ruth_HB’s picture

I thought it might be helpful to include the actual site.

http://www.ruthhong.com/drupal3

The aggregator module is located in the sidebar. You'll notice try clicking on the first link and then the last link. I'm not sure why for the link to the Facebook albums is correct but the link to the wall posts are going to http://www.ruthhong.com/drupal3.

raakesh’s picture

Ruth,

Typically RSS feeds have direct links to resources included in the feed.

If you look at the Facebook feed you are using:
http://www.facebook.com/feeds/page.php?format=atom10&id=115414949761

The album links are working fine because they have the full URL in it, like the one below:

<link rel="alternate" type="text/html" href="<U>http://www.facebook.com/album.php?aid=237838&amp;id=115414949761&amp;comments</U>" />

but the other links are not because those do no have the full URL:

<link rel="alternate" type="text/html" href="/permalink.php?story_fbid=128767417151884&amp;id=115414949761" />
<link rel="alternate" type="text/html" href="/permalink.php?story_fbid=131434916873304&amp;id=115414949761" />
"/permalink.php?story_fbid=128767417151884&amp;id=115414949761"
should be 
"http://www.facebook.com/permalink.php?story_fbid=128767417151884&id=115414949761"

So you need to send out an email to the support team on Facebook and ask them to rectify it.

I won't be surprised if anyone here could provide a solution like scraping the content of the feed, and re-writing it ... I just don't think it's worth the effort. I rather have Facebook fix this once and for all.

Cheers

Raakesh

petsno’s picture

When I add the RSS feed of Drupal (the standard Syndication, no other module) in iGoogle, I also only have the 'shortened' links.
So when I have a link to another page on my site, I get the error

"The requested URL /node/78/lightbox2 was not found on this server. "

Any way around this?

Kind regards,
Peter

staze’s picture

for what it's worth... the facebook feed doesn't even validate.

http://validator.w3.org/feed/check.cgi?url=feed%3A%2F%2Fwww.facebook.com...

Largely because of their use of relative links.

I've submitted a "suggestion". But this seems to have been an issue for a while. The RSS/Atom standard SHOULD support relative links, but it doesn't. So... FB needs to fix this.

staze’s picture

So I made up a very simple php script that I run on my site that fixes the offending FB code. Replace FEEDURL with the full feed URL, and the USERNAME with your facebook username, and this will grab the feed, preg_replace the crappy relative URLs, and replace them with legal absolute URLs.

function get_url_contents($url) {
        //echo $url;
        $crl = curl_init();
        $timeout = 5;
        curl_setopt ($crl, CURLOPT_URL, $url);
        curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
        //curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt ($crl, CURLOPT_HEADER, 0);
        curl_setopt ($crl, CURLOPT_USERAGENT, "Mozilla/4.0");
        $ret = curl_exec($crl);
        curl_close($crl);
        return $ret;
}

$url = 'FEEDURL';
$feed = get_url_contents($url);
$fixed = preg_replace("/<link>\/USERNAME\/posts\//", "<link>http://www.facebook.com/USERNAME/posts/", $feed);
echo $fixed;

For what it's worth, here's the bit FB neglected in implementing their RSS feed.

RSS places restrictions on the first non-whitespace characters of the data in
and elements. The data in these elements must begin with an IANA-registered URI scheme, such as http://, https://, news://, mailto: and ftp://. Prior to RSS 2.0, the specification only allowed http:// and ftp://, however, in practice other URI schemes were in use by content developers and supported by aggregators. Aggregators may have limits on the URI schemes they support. Content developers should not assume that all aggregators support all schemes.

WilliamB’s picture

I'm sorry, could you explain where to put that code?
I found the url of my compagny Facebook page RSS. But yeah it doesn't work through the aggregator module.

Tried adding your code to template.php but it doesnt change anything.