<div class="inner" align="center"> <?php if (isset($_SESSION['username'])) { echo "<b>Hello! " . $_SESSION['username'] . " | people you're following</b>"; //unset($_SESSION['username']); } ?> <div class="all_users" align="center"> <?php $folnonfol = ''; $users = show_users_following($_SESSION['userid']); $following = following($_SESSION['userid']); $follower = follower($_SESSION['userid']); if (count($users)) { ?> <table border="1" cellspacing="0" cellpadding="5" width="330"> <?php foreach ($users as $key => $value) { echo '<tr valign="top">'; echo '<td>' . $value; if (in_array($key, $follower)) { $folnonfol = '| following you'; } else { $folnonfol = ''; //This user is not following you } if (in_array($key, $following)) { echo ' <small><a href="action.php?id=' . $key . '&do=unfollow">unfollow</a> ' . $folnonfol . '</small>';
$str = file_get_contents('user.txt'); $id = intval($str); while (true) { $userArr = $db->get('user', '*', array('id[>]' => $id, 'LIMIT' => 1)); if (!is_array($userArr) || empty($userArr)) { echo "Over!\r\n"; break; } //关注专题/文集 collection($userArr); //构造数据 // $userArr = array('id' => 7231, 'name' => 'f93e84d2e162'); //关注用户 following($userArr); //粉丝 follower($userArr); //文章 articles($userArr); $id = $userArr['id']; file_put_contents('user.txt', $id); $db->clear(); } //关注专题/文集 function collection($userArr) { global $db, $curl; $page = 1; while (true) { $url = "http://www.jianshu.com/users/{$userArr['name']}/subscriptions?page={$page}"; $curl->setUrl($url); $html = $curl->run();