解析一些推文的问题

时间:2017-07-09 16:34:05

标签: php html twitter

我创建了一个函数来解析来自twitter URL的一些数据,这样就嵌入了tuit。此URL取自用户填写的textarea,因为它用于论坛。我允许用户在[twitter]和[/ twitter]标签之间引入Twitter URL,一旦发送,文本就会被PHP处理并提取URL。以下是运行以下代码的地方:

$titulo = "";
$fecha = "";
$nombrecompleto = "";
$nombre_usuario = "";


$url = "https://twitter.com/XboxQwik/status/884071790481256448";

$html = file_get_html($url);

$posts = $html->find('div[class=js-tweet-text-container]');
$titulo = $posts[0]->find('p',0);

$posts = $html->find('div[class=client-and-actions]');
$fecha = $posts[0]->find('span',0);

$posts = $html->find('span[class=FullNameGroup]');
$nombrecompleto = $posts[0]->find('strong',0);

$posts = $html->find('a[class=js-user-profile-link]');
$nombre_usuario = $posts[0]->find('span',1);


$codigo = generateRandomString();

//traducimos la imagen a código html
  $url_html = "<blockquote class=\"twitter-tweet\" data-lang=\"es\"><p lang=\"es\" dir=\"ltr\">" . $titulo . "</p>&mdash; " . $nombrecompleto . " (" . $nombre_usuario . ") <a href=" . $url . ">" . $fecha . "</a></blockquote>";

我一直尝试使用很多tuits并且工作正常,但是通过这个用户,我可以解析它的任何调整。

https://twitter.com/XboxQwik

不知道为什么。

0 个答案:

没有答案
相关问题