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 6365583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:18:41+00:00 2026-05-25T00:18:41+00:00

Hello all having some trouble accessing elements from a returned JSON from Twitter. I’m

  • 0

Hello all having some trouble accessing elements from a returned JSON from Twitter. I’m trying to retrieve about 18 tweets from 6 different account and display them in chronological order, but I can’t figure out how to access the elements in the array. I’ve tried using json_decode(), tried foreach loop and a for loop. Basically I out of all of the following, all I need is the following elements: text, user->screen_name, user->profile_image_url, and created_at. Reason being when I upload the php to a website, the app I’m building times out and doesn’t receive the data, so I’m trying to make the return a lot smaller by only getting back what is needed. Anywho, here is a sample of 1 tweet I’m receiving back…

[{"in_reply_to_status_id":null,"created_at":"Thu Aug 25 01:50:07 +0000 2011","geo":null,"user":{"profile_background_tile":true,"protected":false,"url":"http:\/\/www.backpocketmemory.com","name":"Back Pocket Memory","default_profile":false,"friends_count":1115,"profile_link_color":"0084B4","default_profile_image":false,"show_all_inline_media":false,"contributors_enabled":false,"following":false,"geo_enabled":false,"utc_offset":-28800,"profile_sidebar_border_color":"C0DEED","description":"We're a hard rock\/pop band from Burbank, CA. We love you. facebook.com\/backpocketmemory @bpmchris @bpmguitar @bpmsixstring @bpmbass @bpmdrummer\r\n","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/236635469\/60509_430737311786_16094846786_5566606_2050188_n.jpg","time_zone":"Pacific Time (US & Canada)","created_at":"Mon Jul 27 20:58:35 +0000 2009","profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1320311803\/STICKER_IDEA_1_normal.jpg","is_translator":false,"profile_use_background_image":true,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1320311803\/STICKER_IDEA_1_normal.jpg","follow_request_sent":false,"statuses_count":2238,"profile_background_color":"C0DEED","screen_name":"bckpcktmmry","profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/236635469\/60509_430737311786_16094846786_5566606_2050188_n.jpg","favourites_count":6,"id_str":"60708421","lang":"en","verified":false,"profile_text_color":"333333","location":"Burbank, CA","id":60708421,"listed_count":19,"notifications":false,"profile_sidebar_fill_color":"DDEEF6","followers_count":683},"in_reply_to_user_id":null,"truncated":false,"coordinates":null,"favorited":false,"possibly_sensitive":false,"in_reply_to_status_id_str":null,"in_reply_to_screen_name":null,"source":"\u003Ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003EFacebook\u003C\/a\u003E","in_reply_to_user_id_str":null,"id_str":"106543849266098176","id":106543849266098176,"contributors":null,"place":null,"retweeted":false,"retweet_count":2,"text":"Want to pick up tix for Rob's Bday Show next week? Come visit us at rehearsal. 156 W Providencia in Burbank.... http:\/\/t.co\/oNvw5I6"}]

Any help is appreciated!

  • 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-05-25T00:18:42+00:00Added an answer on May 25, 2026 at 12:18 am

    Your JSON decodes fine:

    array (
      0 => 
      array (
        'in_reply_to_status_id' => NULL,
        'created_at' => 'Thu Aug 25 01:50:07 +0000 2011',
        'geo' => NULL,
        'user' => 
        array (
          'profile_background_tile' => true,
          'protected' => false,
          'url' => 'http://www.backpocketmemory.com',
          'name' => 'Back Pocket Memory',
          'default_profile' => false,
          'friends_count' => 1115,
          'profile_link_color' => '0084B4',
          'default_profile_image' => false,
          'show_all_inline_media' => false,
          'contributors_enabled' => false,
          'following' => false,
          'geo_enabled' => false,
          'utc_offset' => -28800,
          'profile_sidebar_border_color' => 'C0DEED',
          'description' => 'We're a hard rock/pop band from Burbank, CA. We love you. facebook.com/backpocketmemory @bpmchris @bpmguitar @bpmsixstring @bpmbass @bpmdrummer
    ',
          'profile_background_image_url_https' => 'https://si0.twimg.com/profile_background_images/236635469/60509_430737311786_16094846786_5566606_2050188_n.jpg',
          'time_zone' => 'Pacific Time (US & Canada)',
          'created_at' => 'Mon Jul 27 20:58:35 +0000 2009',
          'profile_image_url' => 'http://a2.twimg.com/profile_images/1320311803/STICKER_IDEA_1_normal.jpg',
          'is_translator' => false,
          'profile_use_background_image' => true,
          'profile_image_url_https' => 'https://si0.twimg.com/profile_images/1320311803/STICKER_IDEA_1_normal.jpg',
          'follow_request_sent' => false,
          'statuses_count' => 2238,
          'profile_background_color' => 'C0DEED',
          'screen_name' => 'bckpcktmmry',
          'profile_background_image_url' => 'http://a3.twimg.com/profile_background_images/236635469/60509_430737311786_16094846786_5566606_2050188_n.jpg',
          'favourites_count' => 6,
          'id_str' => '60708421',
          'lang' => 'en',
          'verified' => false,
          'profile_text_color' => '333333',
          'location' => 'Burbank, CA',
          'id' => 60708421,
          'listed_count' => 19,
          'notifications' => false,
          'profile_sidebar_fill_color' => 'DDEEF6',
          'followers_count' => 683,
        ),
        'in_reply_to_user_id' => NULL,
        'truncated' => false,
        'coordinates' => NULL,
        'favorited' => false,
        'possibly_sensitive' => false,
        'in_reply_to_status_id_str' => NULL,
        'in_reply_to_screen_name' => NULL,
        'source' => '<a href="http://www.facebook.com/twitter" rel="nofollow">Facebook</a>',
        'in_reply_to_user_id_str' => NULL,
        'id_str' => '106543849266098176',
        'id' => 106543849266098176,
        'contributors' => NULL,
        'place' => NULL,
        'retweeted' => false,
        'retweet_count' => 2,
        'text' => 'Want to pick up tix for Rob's Bday Show next week? Come visit us at rehearsal. 156 W Providencia in Burbank.... http://t.co/oNvw5I6',
      ),
    )
    

    Echo all the user’s avatars, names, and a date when they joined:

    $data = json_decode($twitter_response);
    foreach($data as $d)
    {
        echo '<img src="' . $d->user->profile_image_url . '" /> ' . $d->user->screen_name . ' (since ' . $d->user->created_at . ')<br />';
    }
    

    If you are using an associative array as your json_decode output, make sure you reference the appropriate keys, like so:

    foreach($data as $d)
    {
        echo '<img src="' . $d['user']['profile_image_url'] . '" /> ' . $d['user']['screen_name'] . ' (since ' . $d['user']['created_at'] . ')<br />';
    }
    

    Working code: http://pastie.org/2436307 (removed single quotes in some values – just escape them or convert them when you decode/reference)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble indexing data.frames in R. I'm an R beginner. I have
I've been tasked with maintaing some legacy fortran code, and I'm having trouble getting
Hello guys I am having some problems with exact matches while doing a NamedQuery.
I am having some trouble as follows: When i add a new user, it
Hello I seem to be having some problem involving counting in Django. I have
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
All of my codes fail. They should print he, hello and 5 \n 3,
Hello again ladies and gents! OK, following on from my other question on ASP.NET

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.