require_once('Facebook.php'); $f = new Facebook(array('appId' => $obj->appid, 'secret' => $obj->seckey)); try{ $m = new Model_Invite(); foreach($requests as $request){ $req = $f->api('/' . $request . '/', 'GET'); if(is_array($req)){ try{ $row = $m->createRow(); $row->to_id = $req['to']['id']; $row->to_name = $req['to']['name']; $row->from_id = $req['from']['id']; $row->from_name = $req['from']['name']; $row->tab_id = $obj->tab_id; $row->save(); }catch(Exception $e){} $f->api('/' . $request . '/', 'DELETE'); } } }catch(Exception $e) { // error handling }