简体   繁体   中英

Twitter get last tweet with twitter API in PHP

How can I get only text from twitter statuses/user_timeline and match it with php regex that return true or false ?

for example I get with this

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
        )

)

I solved it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM