/** * [saveUserInfo 保存用户信息] * @param [type] $tmp_u_id [用户ID] * @return [type] [description] */ function saveUserInfo($tmp_u_id) { $params = array('where' => array('u_id' => $tmp_u_id)); if (!User::existed($params, 'user')) { echo "--------found new user {$tmp_u_id}--------\n"; echo "--------start getting {$tmp_u_id} info--------\n"; $result = Curl::request('GET', 'http://www.zhihu.com/people/' . $tmp_u_id . '/followees'); if (empty($result)) { $i = 0; while (empty($result)) { echo "--------empty result.try get {$i} time--------\n"; $result = Curl::request('GET', 'http://www.zhihu.com/people/' . $tmp_u_id); if (++$i == 5) { exit($i); } } } $current_user = getUserInfo($result); User::add($current_user); echo "--------get {$tmp_u_id} info done--------\n"; } }