2

Ok, something real fishy is going on over on Facebook (what else is new) and I've been researching and testing for more than an hour, with no success.

By using the PHP codes below and I post it on my Facebook wall then click on it, once the page comes up, it does not show the Facebook referral address.

However, if I click on the link where it says "Test link" from my own site, it shows my server and file URL as being the referer.

Anyone else faced with the same problem?

I'm completely baffled.

Here's my code:

<?php

echo $_SERVER['HTTP_REFERER'];

echo "<br>";

echo "<a href=\"test.php\">Test link</a>";

?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141

1 Answers1

5

HTTP_REFERER is not a mandatory HTTP header. Many sites spoof/remove it. Apparently so does Facebook.

Amal Murali
  • 75,622
  • 18
  • 128
  • 150
raidenace
  • 12,789
  • 1
  • 32
  • 35
  • It used to work a month or so ago, when I made another script, worked perfectly. Then BANG, nothing. Any other way it could be done? – Funk Forty Niner Oct 26 '12 at 04:21
  • 1
    Not sure, havent look at FB in a while. However as I said, HTTP_REFERER is not really a stable thing to rely upon, in facebook or any other site.. – raidenace Oct 26 '12 at 04:28
  • Ok thanks. Is there a function on php.net that I could look into instead? – Funk Forty Niner Oct 26 '12 at 04:30
  • what you have in $_SERVER is the as raw as PHP allows you. perhaps you can do a print_r on the whole array and see what the rest of the attributes look like? – raidenace Oct 26 '12 at 04:47
  • I don't know how to do that exactly. I looked it up but can't work my head around it right now. I'll start again tomorrow with a fresh start. – Funk Forty Niner Oct 26 '12 at 04:55
  • Found the problem and I had my doubts last night about what could possibly be at fault and didn't want to fire up (groan) IE, but it seems that Firefox 16.0.1 is at fault, explains it. It worked with IE7 but not FF. Now to spend another 1, or possibly 2-3 hours in trying to find a workaround for that. – Funk Forty Niner Oct 26 '12 at 18:10
  • strange..can you try doing a `print_r($_SERVER);` in both IE and FF and see if there is any difference? Thing is some headers might be recognized by one browser but not another – raidenace Oct 26 '12 at 18:45
  • FF 16 shows a bunch of codes pulled from "my" server, not showing anything coming from Facebook, and IE7 doesn't, only my echo'ed text that it works. – Funk Forty Niner Oct 26 '12 at 18:57
  • Firefox is not recognizing that the referer is Facebook (or any other website the script was linked from) and stops executing. While with IE7, it works perfectly. Mozilla changed something in their last update. – Funk Forty Niner Oct 26 '12 at 19:07
  • 1
    Going over some old questions of mine. Yeah... after all this time and the experience I've accumulated from the time I've been on Stack, have found that it isn't reliable, as per a Q&A here on Stack I've know about for quite some time, being http://stackoverflow.com/q/6023941/ and the accepted answer. *Cheers* - I'll mark as correct. – Funk Forty Niner Apr 30 '15 at 14:58