views:

446

answers:

1

This is the URL I want to share:

http://mydomain.com/#url=http://stackoverflow.com

Inside my site, I do this in Django so that everything will work:

http://mydomain.com/#url={{external|urlencode}}

However, when I pass it to Facebook Share, everything gets messed up.

http://www.facebook.com/sharer.php?u=&lt;url to share>&t=<title of content>

I tried to urlencode the #url part, and also the full url, but it's not working, and my #url is not holding up when there are & and ? signs everywhere.

A: 

I think the problem is, that you first urlencode the last part of url, which you then include into another url.

try use urllib for that:

import urllib
urllib.quote("http://mydomain.com/#url=http://stackoverflow.com")

or when you have to unquote something:

urllib.unquote("http%3A//mydomain.com/%23url%3Dhttp%3A//stackoverflow.com")

kind regards

Joschua