Twitter使用PHP中的twitter API获得最后一条推文

时间:2011-07-15 10:14:39

标签: php api twitter timeline

如何才能从twitter statuses/user_timeline获取文字,并将其与返回truefalse的php正则表达相匹配?

例如我得到了这个

Array (
    [0] => stdClass Object
        (
            [place] => 
            [truncated] => 
            [user] => stdClass Object
                (
                    [default_profile_image] => 
                    [statuses_count] => 1944
                    [profile_background_tile] => 1
                    [protected] => 
                    [contributors_enabled] => 
                    [url] => http://www.mediawebsiteplus.com
                    [name] => Media Website Plus
                    [id_str] => 185200584
                    [is_translator] => 
                    [profile_link_color] => D02B55
                    [follow_request_sent] => 
                    [utc_offset] => 
                    [created_at] => Tue Aug 31 13:04:35 +0000 2010
                    [friends_count] => 1699
                    [profile_sidebar_border_color] => 829D5E
                    [following] => 1
                    [time_zone] => 
                    [profile_image_url] => http://a3.twimg.com/profile_images/1426659184/mwp_logo_normal.png
                    [description] => Media Website Plus adalah jasa pembuatan web, jasa pembuatan website, blog, web sekolah, toko online, dan aneka software murah dan berkualitas tinggi.
                    [profile_use_background_image] => 1
                    [favourites_count] => 0
                    [verified] => 
                    [profile_background_color] => 352726
                    [screen_name] => jasabuatwebsite
                    [listed_count] => 0
                    [profile_background_image_url] => http://a3.twimg.com/profile_background_images/283557264/mwp_logo.png
                    [id] => 185200584
                    [show_all_inline_media] => 
                    [geo_enabled] => 
                    [default_profile] => 
                    [notifications] => 
                    [profile_background_image_url_https] => https://si0.twimg.com/profile_background_images/283557264/mwp_logo.png
                    [profile_text_color] => 3E4415
                    [lang] => en
                    [profile_sidebar_fill_color] => 99CC33
                    [followers_count] => 210
                    [profile_image_url_https] => https://si0.twimg.com/profile_images/1426659184/mwp_logo_normal.png
                    [location] => indonesia
                )

            [id_str] => 91808775270432768
            [in_reply_to_status_id] => 
            [text] => Govt Will Not Increase Subsidized Fuel Prices: “In the remaining time of the year there may be an option to rais... http://bit.ly/qJqn9H
            [created_at] => Fri Jul 15 09:58:12 +0000 2011
            [geo] => 
            [favorited] => 
            [in_reply_to_status_id_str] => 
            [coordinates] => 
            [id] => 9.18087752704E+16
            [in_reply_to_screen_name] => 
            [source] => <a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a>
            [in_reply_to_user_id_str] => 
            [in_reply_to_user_id] => 
            [contributors] => 
            [retweeted] => 
            [retweet_count] => 0
        )

1 个答案:

答案 0 :(得分:0)

我解决了它:

$sep_status = $home_timeline[0]->text;
if (eregi($status, $sep_status)){
    echo "true !";
} else {
    echo "false !";
}