PHP foreach loop to access twitter followers not working -


as question states, trying avatars of each of followers, getting json twitter, , once i've decoded it, try loop through of users profile images url, right getting image tags no url's, so, <img /> "1" or <img /> "2".

here php code:

$followers = json_decode(file_get_contents("http://api.twitter.com/1/statuses/followers.json?screen_name=usersscreenname"), true);  $i = -1;  foreach($followers $value){           $i++;          echo "<img src='".$value[$i]['profile_image_url']."' />";  } 

here when print_r($followers),

array (     [0] => array         (             [contributors_enabled] =>              [following] =>              [verified] =>              [url] =>              [is_translator] =>              [time_zone] => timezone             [profile_text_color] => 739e9f             [profile_image_url] => http://a3.twimg.com/profile_images/000000000/normal.jpg             [description] => description             [status] => array                 (                     [truncated] =>                      [text] => test                     [geo] =>                      [favorited] =>                      [id_str] => 00000000000000                     [retweet_count] => 0                     [coordinates] =>                      [in_reply_to_screen_name] =>                      [in_reply_to_status_id] =>                      [source] => web                     [in_reply_to_status_id_str] =>                      [created_at] => wed feb 09 10:16:51 +0000 2011                     [contributors] =>                      [place] =>                      [retweeted] =>                      [in_reply_to_user_id_str] =>                      [in_reply_to_user_id] =>                      [id] => 5678910                 )              [notifications] =>              [profile_sidebar_fill_color] => 3b615d             [location] => location             [id_str] => 000000             [profile_background_tile] =>              [screen_name] => screen_name             [created_at] => sat apr 18 20:48:58 +0000 2009             [profile_link_color] => b4d9ad             [show_all_inline_media] =>              [follow_request_sent] =>              [geo_enabled] =>              [profile_sidebar_border_color] => aef5fa             [statuses_count] => 1277             [friends_count] => 37             [followers_count] => 38             [protected] =>              [lang] => en             [profile_use_background_image] => 1             [favourites_count] => 38             [name] => name             [profile_background_color] => 214542             [id] => 000000             [listed_count] => 3             [profile_background_image_url] => http://a2.twimg.com/profile_background_images/00000000/qw5ef15qw1fe515weqf1qw5e1f.jpg             [utc_offset] => 7200         )  ) 

that 1 of array elements, there quite few, should sufficient illustrate array structure.

but if try access each users manually this, $img = $followers[0]["profile_image_url"]; works fine, i've checked count , working fine, assuming must doing wrong loop?

thanx in advance!

i'm not sure because i'm not familiar twitter api, think you're using foreach wrong here. $value not array of $followers, item in array of $followers, should not need $i variable @ all. have tried:

//$i = -1;  foreach($followers $value){  //         $i++; //         echo "<img src='".$value[$i]['profile_image_url']."' />";          echo "<img src='".$value['profile_image_url']."' />";  } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -