php - 本地主机上的 Twitter 卡验证器

标签 php twitter meta-tags twitter-card

所以我正在测试 Twitter 和 Facebook 共享功能。

我目前正在测试 Twitter 的分享按钮,我添加了 meta 标签,经过几个小时的搜索,我发现我可以嵌入推文(将 twitter 图片嵌入我的推文链接回我的网站)我需要推特卡片。

我的元代码:

   <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="http://MY_IP_ADDRESS:3000/">
    <meta name="twitter:creator" content="@random">
    <meta name="twitter:title" content="Parade of Fans for Houston’s Funeral">
    <meta name="twitter:description" content="NEWARK - The guest list and parade of limousines with celebrities emerging from them seemed more suited to a red carpet event in Hollywood or New York than than a gritty stretch of Sussex Avenue near the former site of the James M. Baxter Terrace public housing project here.">
    <meta name="twitter:image" content="http://cdn0.lostateminor.com/wp-content/uploads/2015/10/Amazing-long-exposure-photos-make-light-look-like-cobwebs-on-trees2-650x434.jpg">

然后分享按钮看起来像:

  <img src="http://cdn0.lostateminor.com/wp-content/uploads/2015/10/Amazing-long-exposure-photos-make-light-look-like-cobwebs-on-trees2-650x434.jpg">
    <a href="https://twitter.com/intent/tweet?button_hashtag=test" data-url="http://localhost.share.com/" target="_blank">Tweet #test</a>
  </img>

当我发布哈希标签时,它不会选取我的图像或发布它。所以我一直在尝试运行我的网站(我在 Twitter 的 Card Validator 上在我的本地主机上进行测试)https://cards-dev.twitter.com/validator .

我收到此错误消息:error message

知道我做错了什么吗?或者为什么我不能使用我的 IP 地址来测试 Twitter 卡?

谢谢!

最佳答案

我想我会把它留在这里以防有人偶然发现它。因为我很久以前就问过这个问题,所以我实际上不记得周围的工作,但我认为最简单的解决方案是使用 ngrok。

https://ngrok.com/

下载 ngrok。在本地运行您的服务器,然后将 ngrok 指向您的本地服务器正在运行的端口,它会沿着...吐出一些东西

Session Status                online                                                                                                                   
Version                       2.1.18                                                                                                                   
Region                        United States (us)                                                                                                       
Web Interface                 http://127.0.0.1:4040                                                                                                    
Forwarding                    http://65hkdy7ed.ngrok.io -> localhost:3000                                                                               
Forwarding                    https://65hkdy7ed.ngrok.io -> localhost:3000 

然后您就有了要使用的 URL :)

关于php - 本地主机上的 Twitter 卡验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32950819/

相关文章:

php - 从另一个 xpath 查询节点查询 xpath

PHP 正则表达式搜索包含,然后在找到它们的地方写入包含

iphone - 如何以编程方式 "follow"iOS 应用程序中的 Twitter 提要?

php - 自定义 SEO Yoast 的元标记

php - 更改分页中的序列号

php - 使用 Laravel 4 将数据从旧表迁移到新表

php - fatal error : Call to undefined function add_action()

r - twitterr 包 : How to get as many tweets as possible per account within API limits

html - 视口(viewport)初始比例错误

html - 将网站添加到 iOS 主屏幕时,名称字段中显示 "App",如何更改?