Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:29:54+00:00 2026-06-17T10:29:54+00:00

I have retrieved a twitter feed in json format, and when I run this

  • 0

I have retrieved a twitter feed in json format, and when I run this block right on my apacheserver it works fine and delivers a nice table with the twitter feeds.

However, when placed inside a symfony2 controller, it breaks with this error message:

Notice: Undefined property: stdClass::$retweeted_status in /var/www/cloudsign_beta/src/BizTV/ArchiveBundle/Controller/DefaultController.php line 76

The code:

public function TwitterAction($rts, $name, $count)
{

    if ($rts=='on') {
        $rts = 'true';
    }
    else {
        $rts = 'false';
    }

    if ($name=='') {
        //$name = 'warpnine'; 
        //Bazinga!
    }

    if ($count=='') {
        $count = 10;
    }

    $variable = file_get_contents('https://api.twitter.com/1/statuses/user_timeline.json?include_rts='.$rts.'&screen_name='.$name.'&count='.$count);
    $tws = json_decode($variable);

    if (isset($tws)) {
        $r = '<table>';
            foreach ($tws as $tw){
                if ($tw->retweeted_status->id > 0) {
                    $r .='<tr><td class="twitter_td"><img src="'.$tw->retweeted_status->user->profile_image_url.'" class="twitter_img"></td><td>'.
                                $tw->retweeted_status->user->name.
                                ' <i>@'.$tw->retweeted_status->user->screen_name.'</i><br>'.
                                $tw->text.'</td></tr>';
                } else {
                    $r .= '<tr><td class="twitter_td"><img src="'.$tw->user->profile_image_url.'" class="twitter_img"></td><td>'.
                                $tw->user->name.
                                ' <i>@'.$tw->user->screen_name.'</i><br>'.
                                $tw->text.'</td></tr>';
                }
            }
        $r .= '</table>';
    }
    else {
        $r = "Hittade ingen twitterfeed för <strong>$name</strong>";
    }

    return new Response($r);

}   

Here is a var_dump of the $tw first iteration

object(stdClass)#878 (19) { ["created_at"]=> string(30) "Tue Jan 15 15:48:55 +0000 2013" ["id"]=> int(291210363318435841) ["id_str"]=> string(18) "291210363318435841" ["text"]=> string(97) "Looking forward to speaking at Washington and Lee University in Lexington, Virginia, later today!" ["source"]=> string(63) "TweetDeck" ["truncated"]=> bool(false) ["in_reply_to_status_id"]=> NULL ["in_reply_to_status_id_str"]=> NULL ["in_reply_to_user_id"]=> NULL ["in_reply_to_user_id_str"]=> NULL ["in_reply_to_screen_name"]=> NULL ["user"]=> object(stdClass)#875 (38) { ["id"]=> int(287413569) ["id_str"]=> string(9) "287413569" ["name"]=> string(8) "Ron Paul" ["screen_name"]=> string(7) "RonPaul" ["location"]=> string(27) "Clute, TX / Washington D.C." ["url"]=> NULL ["description"]=> string(99) "Former Congressman from Texas, Chairman of Campaign for Liberty, and Champion of the Constitution. " ["protected"]=> bool(false) ["followers_count"]=> int(387763) ["friends_count"]=> int(159) ["listed_count"]=> int(4852) ["created_at"]=> string(30) "Sun Apr 24 23:20:55 +0000 2011" ["favourites_count"]=> int(1) ["utc_offset"]=> int(-18000) ["time_zone"]=> string(26) "Eastern Time (US & Canada)" ["geo_enabled"]=> bool(false) ["verified"]=> bool(true) ["statuses_count"]=> int(976) ["lang"]=> string(2) "en" ["contributors_enabled"]=> bool(false) ["is_translator"]=> bool(false) ["profile_background_color"]=> string(6) "ED1D24" ["profile_background_image_url"]=> string(93) "http://a0.twimg.com/profile_background_images/758570925/9c556d05e88c52861e85356d0cbf1a4c.jpeg" ["profile_background_image_url_https"]=> string(95) "https://si0.twimg.com/profile_background_images/758570925/9c556d05e88c52861e85356d0cbf1a4c.jpeg" ["profile_background_tile"]=> bool(false) ["profile_image_url"]=> string(90) "http://a0.twimg.com/profile_images/3066929869/81d574c68b91e40db69992c0afd34d29_normal.jpeg" ["profile_image_url_https"]=> string(92) "https://si0.twimg.com/profile_images/3066929869/81d574c68b91e40db69992c0afd34d29_normal.jpeg" ["profile_banner_url"]=> string(58) "https://si0.twimg.com/profile_banners/287413569/1357674836" ["profile_link_color"]=> string(6) "DE0A22" ["profile_sidebar_border_color"]=> string(6) "FFFFFF" ["profile_sidebar_fill_color"]=> string(6) "FFFFFF" ["profile_text_color"]=> string(6) "333333" ["profile_use_background_image"]=> bool(true) ["default_profile"]=> bool(false) ["default_profile_image"]=> bool(false) ["following"]=> NULL ["follow_request_sent"]=> NULL ["notifications"]=> NULL } ["geo"]=> NULL ["coordinates"]=> NULL ["place"]=> NULL ["contributors"]=> NULL ["retweet_count"]=> int(96) ["favorited"]=> bool(false) ["retweeted"]=> bool(false) }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:29:56+00:00Added an answer on June 17, 2026 at 10:29 am

    Notice: Undefined property means that ‘retweeted_status’ does not exists in this case (for this item in the loop). As mentioned in the comments, sf2 has strict mode on bydefault (a good thing to improve code).

    Try to add something like

    if(isset($tw->retweeted_status) { }
    

    so your code would look like

    foreach ($tws as $tw){
        if(isset($tw->retweeted_status) {
                if ($tw->retweeted_status->id > 0) {
                    $r .='<tr><td class="twitter_td"><img src="'.$tw->retweeted_status->user->profile_image_url.'" class="twitter_img"></td><td>'.
                                $tw->retweeted_status->user->name.
                                ' <i>@'.$tw->retweeted_status->user->screen_name.'</i><br>'.
                                $tw->text.'</td></tr>';
                } else {
                    $r .= '<tr><td class="twitter_td"><img src="'.$tw->user->profile_image_url.'" class="twitter_img"></td><td>'.
                                $tw->user->name.
                                ' <i>@'.$tw->user->screen_name.'</i><br>'.
                                $tw->text.'</td></tr>';
                }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function that retrieves an image from a twitter feed, the
I have an XML feed that I've retrieved via httpwebrequest, and I'm having problems
I have this code to display the data retrieved from DB in accounts_view.php :
I have a hash that looks like this: extras = {'facebook' => '', 'twitter'
I have implemented Twitter4J in my Android application and it's works fine. But after
I found this great tutorial on how to use JSON to retrieve Twitter updates,
I am using PHP Twitter API to update status on Twitter.I have retrieved the
I am creating an application using the Twitter API. I have retrieved the profile
I have this: $(this).find('a:first'); and is working just fine to retrieve the URL of
I am extremely new to json and have been working on this issue for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.