/** * loop through twitter messages, put them to database and send them to qaul app */ function twitter_process_messages($data, $type) { foreach ($data as $item) { // check if message already exists $msg = MsgQuery::create()->filterByTwitterid($item->id_str)->findOne(); if (!$msg) { // save message in data base $msg = new Msg(); $msg->setType($type); $msg->setName($item->user->screen_name); $msg->setMsg($item->text); $msg->setIp(get_qaul_setting('ip')); $msg->setTime($item->created_at); $msg->setStatus(0); $msg->setTwitterid($item->id_str); $msg->save(); // send message to qaul app twitter_send2qaul($msg); } } }