View Single Post
Old 01-18-2013, 07:15 AM   PM User | #3
cloudstryphe
New Coder

 
Join Date: Mar 2012
Posts: 63
Thanks: 7
Thanked 0 Times in 0 Posts
cloudstryphe is an unknown quantity at this point
Wow. That was super helpful. I wasn't familiar with the array_chunk function. Really helpful. This is the code that ended up working for me.

Code:
$users_array = array();

$i = 0;

$tw_user_array = $twitteroauth->get('friends/ids');

$chunks = array_chunk($tw_user_array->ids, 100);

foreach($chunks as $chunk) {
			
	$cs = implode(",", $chunk);	
		
	$parameters = array('user_id' => "$cs");
		
	$user_objects = $twitteroauth->get('users/lookup', $parameters);
			
	foreach($user_objects as $tw_object) {
					
		$tw_array = array ("id" => $tw_object->id,
						"name" => $tw_object->name,
						"screen_name" => $tw_object->screen_name
						);
								
array_push($users_array, $tw_array);
			}
			
		}
		
		return $users_array;

	}
cloudstryphe is offline   Reply With Quote