Why does facebook change the url when I click on a link? - facebook

Suppose that I click on a facebook link -- once clicked, the URL is transformed to this:
http://www.facebook.com/l.php?u=http%3A%2F%2Fapple.stackexchange.com%2Fquestions%2F398%2Fhow-do-i-build-apps-to-my-jailbroken-ipad&h=uAQFM5WKt
And then I'm redirected to the URL I thought I was going to. Why does facebook do this?

Facebook keeps track of all the links fired from its website. It saves the url you provided as link.
First it forwards you to a facebook link where it saves the url and then it redirects to the actual url.
This way facebook knows which urls are getting most hits.
FYI, Even google does it.

Related

Facebook Share in my website keeps redirecting to website home?

I have a website that I want to share to facebook
https://pvp5.com/item/12057/Sakura-Transient-House
But when facebook fetch the url it always fetch the home url
https://pvp5.com/home
I have a screenshot to prove it. I also did a basic troubleshooting turning off my caching mechanism and website page rules. Why is this happening?
Why is this happening?
Because you explicitly said so, by specifying the Canonical URL as https://pvp5.com/home for all pages.
The canonical URL should be set to the individual URL of that article/piece of content you want to share.

Putting referral URLs into Facebook Like button

I have a site that has referral links. It is set up so that http://site.com/refer/abc redirects to http://site.com/destination.
Whenever I enter http://site.com/refer/abc as the data-href for Facebook's Like button, though, it just rewrites the link as http://site.com/destination, which causes me to lose referral tracking.
Any way I can keep the referral link with the Facebook Like button?
I solved this by checking to see whether it was a bot or human that visited http://site.com/refer/abc. If you're using Rails:
request.env["HTTP_USER_AGENT"].match(/\(.*https?:\/\/.*\)/) ? "is robot" : "is human"
If it was a human, I let it redirect like normal. If it was a bot I just rendered the page with no redirect - the same one that the human would see at http://site.com/destination. This made Facebook keep the original referrer URL but still display the relevant meta tags for that page when someone Liked the page.
EDIT: I've found that if you want Facebook to crawl your Like button right as it's created, you need to curl Facebook's URL linter each time a new button is created:
curl https://developers.facebook.com/tools/lint/?url={YOUR_URL}&format=json
This will update the Like button metadata immediately. More info here.

Does the url I provide for Facebook Like Button need to be exact or can it be one that redirects?

So I'm trying to generate the right URL to go in the facebook Like button. The URL is to a person's facebook page and it's generated using their facebook page's ID.
The facebook like button developers page says that I need to include this URL in the data-href="" attribute in the <div> they provide (that the iframe is generated in).
When I go to a URL like http://www.facebook.com/234h23o4ub23 it redirects to the right place. So I'm wondering if I can get away with using this shorter url as opposed to the url that it redirects to like for example: http://www.facebook.com/pages/example-venue-name/234h23o4ub23. I don't have the "example-venue-name" segment of the URL stored in my database making this method very difficult. Is that page going to register that it was liked or do I have to do the entire URL?
The URL on the like button is actually just what the user will follow back, so as long as the user can follow the link, you will be fine. The link is the unique tracker to the object so that Facebook knows distinct objects.

Feed dialog to event/fan page says "Sorry, something went wrong." after clicking share

Having some issues with the feed dialog when attempting to post to a event or fan page. In my application I am using the JS API and FB.ui using the method feed.
But for a demonstration you can do it using the feed url too for example:
http://www.facebook.com/dialog/feed?app_id=131727613511269&to=287203454659917&redirect_uri=http://www.timeanddate.com/
After clicking share you get the:
Sorry, something went wrong.
We're working on getting this fixed as soon as we can.
Where:
app_id = your app
to = a event / fan page
redirect_uri = a url you are allowed to redirect to
note that the app has publish_stream permissions. (it also has manage_pages for fan pages)
The app in question by the way is: http://apps.facebook.com/tndcountdown/
Thanks,
Andy
EDIT:
An Example taken straight from the documentation:
http://www.facebook.com/dialog/feed?app_id=123050457758183&link=http://developers.facebook.com/docs/reference/dialogs/&picture=http://fbrell.com/f8.jpg&name=Facebook%20Dialogs&caption=Reference%20Documentation&description=Using%20Dialogs%20to%20interact%20with%20users.&message=Facebook%20Dialogs%20are%20so%20easy!&redirect_uri=http://www.example.com/response&to=287203454659917
just replace to=287203454659917 with an event.. (make a test one like it did there)
A few issues I've run into will dialog is that Facebook tries to fill in any missing data. So if you don't provide a description and caption, Facebook will try to scrape the page to get that content. Depending on how the page responds to the "scraping" Facebook will error out. I always make sure I include at least a space for those fields.
It seems the feed url you provided is similar to what is in the documentation. But the demo in the documentation has extra parameters.
I'm about to add page support to my Facebook app, which does the same thing as yours.
http://apps.facebook.com/countdown-timer/
As I posted here - Facebook Send Button - 'Sorry, something went wrong.'...
I had the same problem & worked out that this was due to linking to a Facebook page that did not have a vanity URL set up (i.e. http://www.facebook.com/CubicMushroom rather than http://www.facebook.com/profile.php?id=261963707177053). If you set up a vanity URL for the page it seems to work OK (providing you link to the vanity URL version of the page URL).
To claim a vanity URL, once you have a certain no of like (it used to be 25, but think it's a little lower now) visit https://www.facebook.com/username/

Using Open Graph Protocol to Link Site with Facebook Page

I have a website at http://www.mydomain.com which has a corresponding facebook page at https://www.facebook.com/pages/mydomain/123456789.
I am looking for a way to integrate this facebook page URL into the open graph headers so that when someone shares my page, it actually shares the Facebook page instead of the site's URL.
Is this possible?
You can now do this by setting the og:url meta tag to the url of your Facebook page. Keep in mind that if you do this, other networks that use Open Graph tags will probably share your Facebook page instead of the site's url, so make sure that's what you want.
<meta property="og:url" content="http://www.facebook.com/your-page"/>
Perhaps you already figured this out as this is an old question, but since I stumbled upon it... If I understand your question correctly, you do not even need the ogp meta tags to accomplish what you want to do. All you need to do is go to http://developers.facebook.com/docs/reference/plugins/like/ and input your facebook page url in "url to like", https://www.facebook.com/pages/mydomain/123456789 from your example. Then select the options you want including the "send" button. Then get the code and paste it where you want it in your website. Now whenever someone clicks "like" on your website or clicks "send" to share your website, they will actually be liking or sending the url to your Facebook page and not your website. Is that what you were looking for?