Home >Backend Development >PHP Tutorial >How to get the latest news from twitter in php, _PHP tutorial

How to get the latest news from twitter in php, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 09:57:10938browse

php获取twitter最新消息的方法,

本文实例讲述了php获取twitter最新消息的方法。分享给大家供大家参考。具体实现方法如下:

<&#63;php
function get_status($twitter_id, $hyperlinks = true) {
  $c = curl_init();
  curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml&#63;count=1");
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  $src = curl_exec($c);
  curl_close($c);
  preg_match('/<text>(.*)<\/text>/', $src, $m);
  $status = htmlentities($m[1]);
  if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $status);
  return($status);
}
&#63;>

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/984010.htmlTechArticlephp获取twitter最新消息的方法, 本文实例讲述了php获取twitter最新消息的方法。分享给大家供大家参考。具体实现方法如下: phpfunction get_s...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn