Reputation: 119
I'm trying to make a simple share button LinkedIn using the article share API. It's pretty straight foward, or so I thought.
When using the domain's href
, it works:
https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fsp156.prefeitura.sp.gov.br/portal
I can even make it to another page:
However, if I try another page:
It brings up a error. Looking at the console doesn't really help that much, and at the network tab all the requests return 200.
I tried removing the query parameters, although the page doesn't work without them, and still, didn't worked
@edit: Even the LinkedIn official inspector of pages can recognize the page, now I'm really confused:
Anyone has idea on what's happening? Thanks in advance.
Upvotes: 0
Views: 258
Reputation: 20881
The URL you are sharing contains a ?
character. You need to escape that character using URL-encoding. So, this is what you should want...
https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fsp156.prefeitura.sp.gov.br%2Fportal%2Fservicos%2Finformacao%3Fservico%3D3832
Notice how the ?
is rendered here as %3F
. URL's should only have one ?
at all, because that indicates that $_GET
data is going to proceed that mark. With two of them, the server doesn't know and gets confused!
Looks good to me now!
In case you want to know more: Official LinkedIn Share Documentation
Upvotes: 1
Reputation: 1267
If you browse directly to the landing page of in debug mode you will see that it is returning the error 200 and not linked in.
https://sp156.prefeitura.sp.gov.br/portal/servicos/informacao?servico=3832
Ops, parece que este serviço não existe, busque um serviço na lista ao lado.
Which Google translate says is Oops, it looks like this service doesn't exist, look for a service in the list on the side.
LinkedIn has to redirect to a known good page, that is why the other two resolve. I did notice that there is a login option on that page, is perhaps the page only accessible post login?
Upvotes: 0