I have the following php code on my server that allows me to tell if user cam to my webpage from facebook:
if ($_SERVER[HTTP_REFERER] == "https://www.facebook.com/") { do stuff }
So, the problem here is that people are also using facebook on mobile using facebook app, so I don't get the referral link this way.
Is there any way I can tell if someone came to my webpage clicking on a link using facebook app?
I would suggest to use a regex for matching.
http://php.net/manual/en/function.preg-match.php
For example
if (preg_match("/.*\.(facebook|fbdcn)\.com/i", $_SERVER[HTTP_REFERER])) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
You can use this site to find a good regex.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.