I'm developing an Android html5 app and I wanted to share on Facebook a long URL like:
http://api.myserver.com/share.php?key=[MD5 HASH]
So I first tried:
https://m.facebook.com/sharer.php?u=http://api.myserver.com/share.php?key=[MD5 HASH]
(With the long link URL encoded as parameter) But it didn't work, it says: Link was not found.
I thought it may have something to do with the long MD5 hash that contains the link so I used goo.gl API to shorten it. It returns a string like (without the space):
http://goo. gl/xxxxx
I've tested the shorten links that the Google API returns, and they exists. So I tried again with Facebook:
http://m.facebook.com/sharer.php?u=http://goo. gl/xxxxx
But same thing happens again.
Why does it happen? I've tried to shorten some Instagram url (for example) with goo.gl and... guess what? It works with facebook!
I don't really understand what's wrong with my URL.
all you have to do is to encode the url you want to pass as an argument.
In javascript you can do this with encodeURIComponent.
In fact what happens with your first try is that the hash is considered as a parameter for the facebook's sharer url, due to URL / URI specification.
One has to "url encode" the differents data passed in an url.