如何嵌入Twitter推文

如何嵌入Twitter推文

本文介绍了如何嵌入Twitter推文..如何从推文URL捕获图像并显示实际图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道可以使用哪种方法直接将Twitter推文中包含的视频或图片直接嵌入...例如,..以下是奥巴马的推文

I was wondering what kind of method I could use to directly embed videos or pictures contained in twitter tweets directly ... For example .. below is a tweet from OBAMA

President Obama: "Right now, we have a real chance to reduce gun violence in America." http://t.co/tmCoUsPyyB #TimeToAct

以htttp://开头的链接可能是图片.我如何真正对其编程,以便将推文与URL中的图像直接显示在一起?我知道PHP并且我以前使用过twitter API,但是我不知道如何轻松实现.任何帮助将不胜感激

The link that starts with htttp:// could be a picture .. How can I actually program it so that tweets are directly displayed with the images from the urls ? I know PHP and I used the twitter API before , but I dont know how I could easily achieve that . Any help would be appreciated

推荐答案

第一步是提取文本块的URL,还有另一个问题指出如何解决此问题:

The first step would to to pull the URLs of of the block of text, there is another question that points you how to solve this: Extract URLs from text in PHP

然后,您可以使用Embedly或类似的服务来提取与该URL关联的元数据.这是Embedly将返回的元数据的示例: http://embed.ly/docs/explore/oembed?url=http%3A%2F%2Ft.co%2FtmCoUsPyyB

You can then use Embedly or a service like it to pull the metadata associated with that url. Here is an example of the meta data that Embedly will return: http://embed.ly/docs/explore/oembed?url=http%3A%2F%2Ft.co%2FtmCoUsPyyB

html属性是您要在页面上呈现的内容.

The html attribute is what you want to render on your page.

我们还有一个您也可以使用的PHP库.

We also have a PHP library you can use as well.

希望有帮助!

这篇关于如何嵌入Twitter推文..如何从推文URL捕获图像并显示实际图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 15:10