Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly encode image URL with equal sign for Facebook open graph tag

I have a page with an Open Graph image tag:

<meta property="og:image" content="http://childhumor2.homeip.net:9009/_ah/img/RYCF7Ty7wODp9R-N_QIWYA===s200"/>

The image is a GAE blob and the URL comes from calling get_serving_url. The URL works fine normally.

Now, if someone likes this page, the thumbnail image that is shown in the newsfeed is broken. Only a blank 1x1 image is returned to the browser.

Inspecting the FB page, the generated HTML is:

<img src="http://external.ak.fbcdn.net/safe_image.php?d=6b635a7f80252e93c6b28e2dbe4ad440&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fchildhumor2.homeip.net%3A9009%2F_ah%2Fimg%2FRYCF7Ty7wODp9R-N_QIWYA%3D%3D%3Ds200" class="img">

When viewing the liking user's news feed for the first time, I see FB hit my server for the image:

INFO     2010-11-14 21:33:17,701 dev_appserver.py:3283] "GET /_ah/img/RYCF7Ty7wODp9R-N_QIWYA%3D%3D%3Ds200 HTTP/1.1" 500 -

It is obvious that there is a URL encoding problem with the equal signs in the URL but I have no idea who is at fault here.

  • Should FB be unescaping %3D before calling back to my server for the image?
  • Is GAE not properly handling an encoded URL?
  • Should I be encoding the URL in the Open Graph tag somehow? (I tried urllib.quote-ing it with the same results.)

To make things more confusing, the Facebook URL Linter retrieves the image properly. Also if doing a FB share on the page, the thumbnail preview will be shown correctly. This leads me to believe this is a bug with the safe_image.php script FB is proxying/caching the image with.

like image 459
cope360 Avatar asked Oct 27 '25 05:10

cope360


2 Answers

It is probably the case that Facebook should be unquoting the value so that it matches the original og:image you listed, and you should write a bug for that (as Nathan suggested).

However, technically speaking %3D and = have the same meaning in the path section of a URL and should be treated equally so that might also be bug worthy on the GAE side of things. In this case you probably want to urllib.unquote() the path when handled on GAE. (perhaps you could simply redirect to the unescaped version)

like image 111
Jehiah Avatar answered Oct 28 '25 19:10

Jehiah


If the URL linter says everything is working correctly, then you are most likely correct that it is a bug with Facebook. I would recommend searching through their existing bugs to see if you can find one that exists, and if not post a new bug. There are currently about 4,300 platform bugs open so it is certainly not unheard of that something is broken. Facebook Bugs: http://bugs.developers.facebook.net/

like image 33
Nathan Totten Avatar answered Oct 28 '25 19:10

Nathan Totten