Pinterest could not fetch the image

只谈情不闲聊 提交于 2019-12-12 15:37:19

问题


Trying to implement the "pin it" button but it returns the following problem for every single image. We use SSL across the whole site and I'm wondering if this is related.

Any idea?

{"route_pattern": "^/resource/:name/:method/$", "error": {"api_error_code": 1, "message": "Sorry we could not fetch the image.", "code": "API_ERROR", "target": "<webapp.resources.pin_resource.PinResource object at 0xb851c50>", "http_status": 400}, "resource": {"name": "PinResource", "options": {"board_id": "393150311159619967", "description": "Kokeshi - Samoura\u00ef Bento", "link": "https://bentooo.com/products/kokeshi-samourai-bento", "image_url": "https://bentooo.com/upload/pictures/884/thumb/IMG_0704.jpg", "bookmarks": ["-end-"], "is_video": null, "method": "button"}}, "client_context": {"app_version": "5bdef68"}, "resource_response": {"data": null, "error": {"api_error_code": 1, "message": "Sorry we could not fetch the image.", "code": "API_ERROR", "target": "<webapp.resources.pin_resource.PinResource object at 0xb851c50>", "http_status": 400}}}

回答1:


We were having exactly the same issue, everytime. Also suspected issues with our .htaccess file Rewriting non-SSL to SSL traffic.

    "resource_response": {
    "data": null,
    "error": {
        "api_error_code": 1,
        "message": "Sorry! Something went wrong on our end. Please try again.",
        "code": "API_ERROR",
        "target": "<webapp.resources.pin_resource.PinResource object at 0x7f0c9b421e50>",
        "http_status": 400
    }
}

This worked for us; not sure if it helps anybody else? We simply updated .htaccess to include an exclusion on the Rewrite where HTTP referer matches *.pinterest.com and then make sure that the &media=value was referencing a media resource using non-SSL schema.

Example:

RewriteCond %{ENV:siteENV} PROD
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_REFERER} !(?:pinterest.com)
RewriteRule (.*) https://www.somedomain.com%{REQUEST_URI} [L,R=301]

And the pin code. Note the non-SSL &media=value.

<a href="//pinterest.com/pin/create/button/?url=https://www.somedomain.com/mypage&media=http://www.somedomain.com/assets/images/myimage.jpg&description=Some%20urlencoded%20description" data-pin-do="buttonPin" data-pin-config="beside">
<img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" />
<img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_red_28.png" />
</a>


来源:https://stackoverflow.com/questions/18394573/pinterest-could-not-fetch-the-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!