We have a requirement of not sending a specific ajax request to our server if the page is requested by Facebook scraper (we share the link to our page on the facebook wall) and we try to check the user-agent in javascript based on https://developers.facebook.com/docs/sharing/webmasters/crawler/ but we noticed that we are getting quite many requests by facebook IP address with normal user-agents (like "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36") is it a bug? Any workaround (except looking for facebook ip-addresses)?
The mentioned User-Agent only comes into play when the Facebook scraper requests your URL - but the scraper doesn’t execute any JS to begin with, so trying to “suppress” any AJAX requests in that scenario doesn’t make sense to begin with - because there simply aren’t any.
if the page is running by Facebook
Can you please clarify what you actually mean by that? “Running by Facebook” is not really phrasing that makes much sense.
So please explain in what exact scenario you need to suppress this AJAX request. Are you talking about a normal page visit in the Facebook in-app browser? Or a context where your content gets embedded on Facebook, like a Page Tab or Web Games app, or Instant Gaming, or …?
Related
As I mention on title, I'm finding a solution to detect whenever user click on my website from Facebook.
I 've try to do that by reading userAgent from the request, that user agent may be a string look like this when the my site is opened on Facebook 's internal webview:
*Mozilla/5.0 (Linux; Android 9; Redmi Note 8 Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.81 Mobile Safari/537.36 [**FB_IAB**/Orca-Android;**FBAV**/280.0.0.16.110;]*
and then with keyword FB_IAB I can find out that the user clicked from Facebook.
But there still a problem that on some device, when user click the link on Facebook, it doesn't open the internal webview but open external browser. So that I got the user-agent like this:
*Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/71.0.3578.141 Safari/534.24 XiaoMi/MiuiBrowser/12.5.2-go*
(behavior on Xiaomi). Thus, I can not detect user agent is from Facebook or not.
Could you please suggest me the way to solve this problem ? Thank you!
I have a website in Joomla hosted on my own vps. I have installed plugin for meta og, but share on facebook still give an 403 error. I've checked the facebook debugger, and it's like it can not resolve the url (bad http response).
Other tools for social analysis of the page show me the page and the meta correctly, and other social sharer like google+ work good. Only facebook sharer is broken.
I have tried with gzip on and off, but still 403 forbidden.
Someone know how can i make it work?
Thanks in advance!
Ok, I solved this: there was a mod_security rule (protocol violations) that was blocking the sharer of Facebook. If I remove that rule, facebook sharing is ok.
So, I am not an expert of mod_security, but I don't think it's good thing to remove completely a security rule.. Do you know if it is possible to write a specific exception?
I'm trying to link to individual Facebook posts and display the post page's meta data, including an image preview, but looking at the FB post page's source, it has none of the usual meta nor open graph tags.
I found that LinkedIn and Google Plus are able to retrieve meta data when you post a link to a facebook post. See below for a LinkedIn example.
How are they doing it!?
I'm not insider of LinkedIn or Google so not sure of it. But there're two ways they can do it:
Analysing the structure of facebook post and fetch the picture/title/content of post from url.
Fetch post id of the post (fbid), and use graph api to query the details of the post from facebook.
What I wanted to do was get the post page's metadata which wasn't appearing when I requested the url from my server using http.
But what I received was Facebook's error page for "Update your browser"
So I added ...
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0
... to the header. And it worked.
I currently have an app that uses a webview to show my website.
The webview is only allowed to access a certain page of my website and no other devices are allowed to access it.
I'm restricting this with a user agent that Titanium SDK gives me: Titanium.userAgent
"Appcelerator Titanium/3.5.0 (iPhone Simulator/8.1; iPhone OS; en_US;)"
Unfortunately this gives me a fairly poor looking Facebook login when I go to login with Facebook on my website through the webview.
The Facebook login looks fine though if I use the default user agent from the webview (basically by not setting the user agent manually and just leaving it). But unfortunately, this default webview user agent is the same as any other mobile browsers user agent, so I can't tell them apart from the app or a mobile browser to redirect them to the correct places on my website.
And unfortunately on iOS, there's a bug in Titanium where you cannot get the default user agent (webView.getUserAgent() or webView.userAgent return undefined on iOS).
So I was wondering exactly what I need to do to my custom user agent string here:
"Appcelerator Titanium/3.5.0 (iPhone Simulator/8.1; iPhone OS; en_US;)"
To make it so the Facebook login looks clean and smooth, because the above user agent, while it redirects my users to the correct place, gives me a poor looking Facebook login. What do I need to add to this string?
This is the default webview user agent string that gives me a good looking Facebook login page:
""Mozilla/5.0 (iPhone; CPU iPhone OS 10_9_5 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B411"
I got it working by simply appending the user agent I retrieved from my access logs to the one Titanium SDK gives me:
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_9_5 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B411"
I have integrated facebook sdk in iphone app. It was working fine. But, suddenly, it stopped showing "Facebook login page" in dialog, as it is shown in screenshot. I tried it with different facebook api key, secret and it worked fine, but its not working with my old api key, secret. Please help me in this.
Thank you.
I had this problem exactly the same with yours.
I managed to figure out that the user-agent I was setting is not recognized by facebook login dialog (which is a webview).
Facebook login dialog takes default user-agent, which should look like this:
Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A334. So leaving the user-agent default could be a good try.
Not sure if you still have this problem since this question has been a long while. Just to leave a message for who are facing this problem and are looking for a possible solution.