Facebook搜寻器无法验证og:image网址 [英] Facebook scraper not validating og:image url

查看:129
本文介绍了Facebook搜寻器无法验证og:image网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在控制器上运行一些功能,以提供一个自定义的元标记URL,然后将其用于Facebook的opengraph图像标记.该图像被放入变量中,然后显示在用于在Facebook上抓取的网址上.我使它以正确的方式工作,现在短绒棉鞋因这个错误再次出现在我身上.

I am running some functions on my controller to come up with a custom meta tag url that is then taken and used on the opengraph image tag for facebook. This image gets put in a variable, that then gets displayed on a url used for scraping on facebook. I got it working the right way and now the linter comes back at me with this error.

类型为网站"的URL'http://mypage.org/pages/post.html?PostID=9192&prog='上的对象无效,因为属性'og:image:url'的给定值''无法解析为'url'类型.

Object at URL 'http://mypage.org/pages/post.html?PostID=9192&prog=' of type 'website' is invalid because the given value '' for property 'og:image:url' could not be parsed as type 'url'.

这是无效的网址吗?我可以将链接放在浏览器中,然后就可以了.我也注意到,当我下楼看到抓取的网址时,它也带回了我.

How is that not a valid url? I can take the link and put it in my browser and it comes up just fine. I notice as well when I go down to see the scraped url it gives me back this..

<meta property="og:image" content="&lt;img src='http://www.mypage.org/images/post_images/4121.jpg' /&gt;">

好像需要我<和/>,使其变成十六进制..为什么刮刀会这样做呢?顺便说一下,这是我的控制器中的代码.

Looks like it takes my < and />, makes them into hex..why would the scraper do this? Btw here is the code from my controller.

$img = strstr($img, '<img src=');
$substring = substr($img, 0, strpos($img, "/>"));
$img = $substring . "/>";

此代码的作用是我将URL之前的代码带到完整的<img src = "" />网址的末尾.任何帮助都将不胜感激.

What this code does is I take the code before the to the end of the url making a full <img src = "" /> url. Any and all help is very much appreciated.

推荐答案

您不应将HTML标记嵌入meta标记的内容中.尝试使用以下格式:

You shouldn't embed the HTML tag into the content of the meta tag. Try this format instead:

<meta property="og:image" content="http://www.mypage.org/images/post_images/4121.jpg">

这篇关于Facebook搜寻器无法验证og:image网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆