public function cache() { $user= User::identify(); $twit= new Bridge(); $count= $twit->getFollowerCount(); $numpages = ceil($count/100.0); for ($i=1; $i<=$numpages;) { $followers= $twit->getFollowers($i); foreach($followers as $follower) { if($follower['location'] != null) { $url= 'http://local.yahooapis.com/MapsService/V1/geocode?appid=uGnX5KbV34EODF_qr6lEnvIJYXzOIvK1Sy6jPj5rJ43n9jnzqpKzWSei4.o_m.XfWtoV&location='; $geocode= new RemoteRequest($url . $follower['location']); $geocode->execute(); if($geocode->executed() != false) { $response = $geocode->get_response_body(); $xml = @new SimpleXMLElement( $response ); $twit_city= (string)$xml->Result->City; $twit_state= (string)$xml->Result->State; if($twit_city != '') { $city= $twit_city . ', '; } else { $city= ''; } if($twit_state != '') { $state= $twit_state; } else { $state= ''; } } } else { $city= ''; $state= ''; } DB::query( 'INSERT INTO tim__followers ( tim_id, name, location ) VALUES ( ?, ?, ? )', array( $user->id, $follower['screen_name'], $city . $state ) ); } $i++; } $user->info->cached= 1; $user->info->commit(); }