我是靠谱客的博主 优美期待,这篇文章主要介绍插件58:接收tweet消息,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php // Plug-in 58: Get Tweets /* * 插件说明: * 插件从一个公开的Twitter用户中读取最后20条Tweet消息。 * 接受一个Twitter账户的用户名,如果它是公开的,则返回它最近的Tweet消息。 * 访问成功,则返回一个两元素的数组,其中第一个元素表示Tweet消息的个数,第二个元素包含一个数组,保存每个Tweet消息。 * 访问失败,则返回只有一个元素的数组,这个元素的值为FALSE。它需要以下参数: * $user Twitter用户名。 */ // This is an executable example with additional code supplied // To obtain just the plug-ins please click on the Download link $user = 'eminem'; $result = PIPHP_GetTweets($user); echo "Viewing '$user':<br /><ul>"; if (!$result[0]) echo 'Failed'; else for ($j = 0 ; $j < $result[0] ; ++$j) echo "<li>" . $result[1][$j] . "</li>"; function PIPHP_GetTweets($user) { // Plug-in 58: Get Tweets // // This plug-in returns the most recent 20 tweets of a Twitter // user. The argument required is: // // $user: Twitter username // // Upon success the plug-in returns a two element array, the // first of which contains the number of tweets returned, and // the second is an array of the tweets. On failure a single // element array is returned with the value FALSE. $url = "http://twitter.com/statuses/user_timeline/$user.xml"; $file = @file_get_contents($url); if (!strlen($file)) return array(FALSE); $xml = @simplexml_load_string($file); if ($xml == FALSE) return array(FALSE); $tweets = array(); foreach ($xml->status as $tweet) { $timestamp = strtotime($tweet->created_at); $tweets[] = "(" . date("M jS, g:ia", $timestamp) . ") " . $tweet->text; } return array(count($tweets), $tweets); } ?>

最后

以上就是优美期待最近收集整理的关于插件58:接收tweet消息的全部内容,更多相关插件58内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部