Facebook喜欢按钮 - 图像未显示在新闻Feed上

时间:2011-09-05 07:20:10

标签: facebook opengraph

  

可能重复:
  How does Facebook Sharer select Images?

我添加了链接按钮和og标签。 我在linter上检查了我的页面并且没有报告错误,但是没有显示图像。但是,如果我点击图像所在的占位符,它会链接到正确的图像。有谁知道为什么?

我正在使用asp.net mvc3并链接到我的图片如下所示:http://www.domain.com/gallery/thumb/222/test-image.png

test-image.png在服务器上不存在,我使用id(222)找到正确的图像并用内容配置显示它,test-image仅适用于SEO。这可能是个问题吗?

1 个答案:

答案 0 :(得分:0)

如果您尝试使用cURL或wget检索图像(来自评论),则会获得500:

$ wget http://noa-yachting.mlaen.com/Gallery/Thumb/99/200/hanse-495-croatia-charter.png
--2011-09-06 07:41:49--  http://noa-yachting.mlaen.com/Gallery/Thumb/99/200/hanse-495-croatia-charter.png
Resolving noa-yachting.mlaen.com... 178.218.172.36
Connecting to noa-yachting.mlaen.com|178.218.172.36|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2011-09-06 07:41:49 ERROR 500: Internal Server Error.

$ response=`curl --write-out %{http_code} --silent -k -G http://noa-yachting.mlaen.com/Gallery/Thumb/99/200/hanse-495-croatia-charter.png`
$ echo $response
 This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.-->500

只要您提供一个返回图像字节的链接,并在向它发出HTTP GET时就会发出200 OK响应,那么您就可以了。

我还下载了图像并将其上传到我自己的服务器并将其添加到OG页面 - 它就像一个魅力。所以,问题的答案是,为什么ASP.net在浏览器请求时正确返回图像,而不是在cURL或wget请求时?

我没有什么可继续的,你做的事情就是当用户进入你的主页然后在提供图像之前检查那个会话时创建会话吗?我确实有一堆来自你域名的cookie,所以这似乎至少看似合理。如果是这样,您需要允许每个人都可以查看该图像,或者至少找到Facebook抓取工具的用户代理并始终允许它查看图像。

更新: 在查看页面URL之前在干净的浏览器中查看图像,图像仍然可以正常加载,因此我认为这不是问题所在。我从来没有使用过ASP或IIS,所以我的想法已经不多了,但这肯定是你的问题。

更新2: 得到它了! cURL中的详细输出ftw。这就是服务器正在生成的内容:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below

[NullReferenceException: Object reference not set to an instance of an object.]
   NoaYachting.ClientSite.Controllers.BaseController.ExecuteCore() in D:\DEV\NoaYachting\NoaYachting\NoaYachting.ClientSite\Controllers\BaseController.cs:69
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

我担心你会自己解决这个问题:)

相关问题