How to Encode Equal-Sign Image URL for Facebook

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 block, and the URL comes from the call get_serving_url. The url is working fine.

Now, if someone liked this page, the thumbnail image displayed in the news feed is broken. Only a blank 1x1 image is returned to the browser.

Checking the FB generated HTML page:

<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 a user's favorite news feed for the first time, I see that 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 -

Obviously there is a problem with the encoding of the URLs with equal characters in the URL, but I don't know who is to blame.

  • Should FB cancel% 3D before accessing my server for an image?
  • Is GAE handling encoded URLs incorrectly?
  • URL- Open Graph? ( urllib.quote-ing .)

, Facebook URL Linter . , FB , . , safe_image.php script FB - / .

+3
3

URL- linter , , , , , Facebook. , , , , . 4300 , , , , - . Facebook: http://bugs.developers.facebook.net/

+1

, Facebook , og: image, , ( ).

%3D = URL- , GAE. , , urllib.unquote() GAE. (, )

+3

Google. , blob , . URL-, Facebook.

GAE Docs:

class Thumbnailer(webapp.RequestHandler):
    def get(self):
        blob_key = self.request.get("blob_key")
        if blob_key:
            blob_info = blobstore.get(blob_key)

            if blob_info:
                img = images.Image(blob_key=blob_key)
                img.resize(width=80, height=100)
                img.im_feeling_lucky()
                thumbnail = img.execute_transforms(output_encoding=images.JPEG)

                self.response.headers['Content-Type'] = 'image/jpeg'
                self.response.out.write(thumbnail)
                return

      # Either "blob_key" wasn't provided, or there was no value with that ID
      # in the Blobstore.
      self.error(404)
0

Source: https://habr.com/ru/post/1774830/


All Articles