function get_social_tags($id) { $follower_array = array(); $follow_array = get_follows($id); $merged_array = array(); $tags = array(); foreach (get_follows($id) as $follow) { $fame = get_tags($follow); if (0 < count($fame)) { foreach (get_followers($follow) as $follower) { $follower_array[] = $follower; } foreach ($follow_array as $element1) { foreach ($follower_array as $element2) { if ($element1 == $element2) { $merged_array[] = $element1; } } } if (tag_shade_filter(count($merged_array), count($follow_array))) { foreach ($fame as $added_tag) { $tags[] = $added_tag; } } } } $tags = array_unique($tags); return $tags; }
function get_follow_rate($user_id) { $follows = get_follows($user_id); $followers = get_followers($user_id); $follower_cnt = 0; foreach ($follows as $follow) { if (array_key_exists($follow, $followers)) { $follower_cnt++; } } if (0 == count($follows)) { return 0; } else { return round($follower_cnt / count($follows) * 100); } }
function copy_followers($connection, $db, $myScreenName, $count, $targetCount, $debug, $cursorTarget, $twitterUser, $date, $email, $debugEmails, $name) { $followersComprehensive = get_followers($connection, $myScreenName, 5000, $debug, true, false); echo '<br>Retrieved your followers. . .'; $friendsComprehensive = im_following($connection, $myScreenName, $count, $debug, 'ids'); echo '<br>Retrieved who you\'re following. . .'; // Following logic $numberOfFollowers = number_of_followers($connection, $myScreenName, true); $numberOfFriends = number_of_followers($connection, $myScreenName, false); echo "<br>{$myScreenName} has {$numberOfFollowers} followers"; echo "<br>{$myScreenName} has {$numberOfFriends} friends"; $numberOfRequests_USER = (int) ($numberOfFollowers + $numberOfFriends) / 5000; //echo "<br>Number of Twitter API requests made on $myScreenName: $numberOfRequests_USER"; $numberOfRequests = (int) 15 - ceil($numberOfRequests_USER); // Request as many followers from the user as possible //echo "<br>Number of requests to make on $twitterUser: $numberOfRequests_target"; $targetFollowersComprehensive = get_followers($connection, $twitterUser, 5000, $debug, false, $numberOfRequests); echo '<br>Targeted followers to follow.'; $targetFollowersNarrowed = array_diff($targetFollowersComprehensive, $followersComprehensive, $friendsComprehensive); if ($debug) { echo '<br>NARROWED TARGET FOLLOWERS:<BR>'; print_r($targetFollowersNarrowed); } echo "<br>Narrowed target followers."; $message = ''; $i = 1; foreach ($targetFollowersNarrowed as $targetFollower) { $isFollowing = in_array($targetFollower, $followersComprehensive); $imFollowing = in_array($targetFollower, $friendsComprehensive); //echo "$targetFollower: ".( $isFollowing ? 'OK' : '!!!' )."<br/>"; if (!$isFollowing && !$imfollowing) { $parameters = array('user_id' => $targetFollower); $userID = $parameters['user_id']; //if($debug){echo "Possible follower detected: ".$userID."<br>";} //Investigate User Before Following $userInvestigationURL = "https://api.twitter.com/1.1/users/lookup.json?user_id={$userID}"; $userInvestigation_json = $connection->get("{$userInvestigationURL}"); $errorObject = $userInvestigation_json->errors; $ErrorCode = $errorObject[0]->code; $ErrorMessage = $errorObject[0]->message; if ($ErrorMessage != '') { if ($debug) { echo "<div class='errorMessage'>Could not research potential user. " . $ErrorMessage . ".</div>"; } break; } $userInvestigation_array = $userInvestigation_json[0]; $requestScreenName = $userInvestigation_array->screen_name; $followRequestSent = $userInvestigation_array->follow_request_sent; $followingUser = $userInvestigation_array->following; $followersCount = $userInvestigation_array->followers_count; $friendsCount = $userInvestigation_array->friends_count; $favoritesCount = $userInvestigation_array->favourites_count; if (!$debug) { $message .= '<small id=' . $userID . ' class="user_info">'; $message .= "Screen Name: {$requestScreenName}<br>"; //echo "UserID: $userID<br>"; $message .= "Follow Request Sent: "; if ($followRequestSent) { $message .= 'Yes'; } else { $message .= 'No'; } $message .= '<br>'; $message .= "Already Following: "; if ($followingUser) { $message .= 'Yes'; } else { $message .= 'No'; } $message .= '<br>'; $message .= "Following more than followed: "; if ($friendsCount > $followersCount) { $message .= 'Yes'; } else { $message .= 'No'; } $message .= '<br>'; $message .= "Active (more than 10 favorites): "; if ($favoritesCount > 10) { $message .= 'Yes'; } else { $message .= 'No'; } $message .= '<br>'; $message .= '</small>'; } // if ((!$followRequestSent) && (!$followingUser) && ($friendsCount > $followersCount) && ($favoritesCount > 10)) { if (!$followRequestSent && !$followingUser && $favoritesCount > 10) { $followUsers_json = $connection->post("https://api.twitter.com/1.1/friendships/create.json?user_id={$userID}&follow=true"); // DB work /* $query = "SELECT userID FROM users WHERE screenName like '$myScreenName';"; $result = $db->query("$query"); $myDBUserID = $result->current_field; $query = "INSERT INTO followers (`userID`, `followerID`) VALUES ('$myDBUserID', '$userID');"; $result = $db->query("$query"); */ if ($debug) { echo '<small>'; print_r($followUsers_json); echo '</small><br>'; } $followingUser = $followUsers_json->following; $errorObject = $followUsers_json->errors; $error = $errorObject[0]->code; if ($followingUser && $error != '160' || $followingUser && $error != '161') { /* echo "<div class='followed'>"; echo "<h4>$i accounts followed.</h4><br>"; echo '</div>'; echo "<br><hr><br><br>"; */ } $i++; } } if ($error == '161') { break; } } $messageDebug = $message; $k = $i - 1; echo "<div class='followed'>"; echo "<strong>{$k} accounts followed.</strong> To follow more, wait 15 minutes past: "; $date = new DateTime(); echo $date->format('h:i:s'); echo '</div>'; echo '<br>'; if ($k < 5) { $date = new DateTime(); $time = $date->format('h:i:s m-d-Y'); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "To: {$name}" . "\r\n"; $headers .= 'From: Scavenger App <*****@*****.**>' . "\r\n"; // The message $message = "<html><head><title>Scavenger App Mail</title></head><body>"; $message .= "<div>@{$myScreenName} followed only {$k} of @{$twitterUser}'s followers. The app might have reached all of their followers. If you see this same email a couple more times, go to <a href='http://scavenger-app.com/scavenger/set-user.php'>Set User</a> to follow a different user list!</div><br>"; $message .= "<h2>Debugging - {$time}</h2><br>"; $message .= "<small>{$messageDebug}</small>"; $message .= "<br><br>Sincerely,<br>The Scavenger App"; $message .= "</body></html>"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70, "\r\n"); // Send mail($email, "@{$myScreenName} Followed < 5 of @{$twitterUser}'s Users", $message, $headers); } else { $date = new DateTime(); $time = $date->format('h:i:s m-d-Y'); if ($debugEmails) { // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "To: {$name}" . "\r\n"; $headers .= 'From: Scavenger App <*****@*****.**>' . "\r\n"; // The message $message = "<html><head><title>Scavenger App Mail</title></head><body>"; // The message $message .= "<div>@{$myScreenName} followed {$k} people who follow @{$twitterUser} and finished at {$time}.</div>"; $message .= "</body></html>"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70, "\r\n"); // Send mail($email, "@{$myScreenName} Followed @{$twitterUser}'s Users", $message, $headers); } } return $cursorTarget; }
$tmhOAuth = new tmhOAuth(array( 'consumer_key' => ConsumerKey, 'consumer_secret' => ConsumerSecret )); $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token']; $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret']; //Twittear if ($_COOKIE['twitear'] != "no") { $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array( 'status' => "Usando las Twit-Herramientas \"Test de reciprocidad\": Descubre gente a la que que sigues pero no te sigue a ti. " . KCY, )); } // Conseguir Followers get_followers(); //Conseguir Firends get_friends(); // if ($followers['num'] == 5000 || $friends['num'] == 5000) { // echo("<p align=\"center\">Atención: Tienes más de 5000 followers o sigues a más de 5000 personas.<br> // La operación se realizará con los 5000 más recientes.</p>"); // } //Comparar foreach ($friends['ids'] as $hamijo) { if (!in_array($hamijo, $followers['ids'])) { $traidores[] = $hamijo; } } If (count($traidores) != 0) {
if(strstr($row["follow"],($_GET["user"])==true)){*/ //$user = $_GET["user"]; echo "<form style=\"float: right;\" action=\"\" method=\"post\">"; echo " <input type=\"image\" src=\"" . $pth . "inc/icons/-.png\" name=\"status_id_menos\" value=\"" . $user . "\"> <small>" . $loginphp_ufl . "</small> "; echo "</form>"; //}else{} } ?> <br> <?php //Si es usuario muestra a quien sigue if ($_GET["user"]) { echo "<h3>"; name($_GET["user"]); echo " is following to...</h3>"; $flw = get_followers($_GET["user"]); if ($flw == "") { echo "nobody!"; } else { $following = explode(",", $flw); $i = 0; $t = 0; while ($following[$i] == true) { $queryw = "SELECT id_usr,nick,correo, gravatar FROM mt_users Where id_usr = '******' LIMIT 1"; $resultw = mysql_query($queryw, $connuni) or die(mysql_error() . ': ' . $queryw); while ($ruw = mysql_fetch_assoc($resultw)) { if ($ruw["gravatar"] == "yes") { echo "<a href=\"index.php?user="******"id_usr"] . "\" title=\"" . $ruw["nick"] . "\" onmouseover=\"Tip('"; echo "<b>" . $ruw["nick"] . ": </b>"; echo last($ruw["id_usr"]); echo "', BALLOON, true, ABOVE, true, OFFSETX, -17, PADDING, 8)\" onmouseout=\"UnTip()\">";
function test_get_followers() { $result = get_followers(2); $this->assertEquals($result, 1); }
<?php require 'init.php'; $user_id = $_GET['id']; if (!get_username_by_user_id($user_id)) { display_not_found_page(); } $followers = get_followers($user_id); $page_url = APP_URL . '/user.php?id=' . $user_id; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['follow'])) { follow_user($user_id, get_current_user_id()); redirect($page_url); } else { if (isset($_POST['unfollow'])) { unfollow_user($user_id, get_current_user_id()); redirect($page_url); } } } $follower_count = get_follower_count($user_id); ?> <!DOCTYPE html> <head> <meta charset="utf-8"> <title>Tubogram</title> <?php echo js_and_css(); ?> </head>
<div id="relations"> <p id="following"> <a href=" <?php echo make_url("relations", "following", esc($uname)); ?>"> <strong>Following</strong><br /><?php echo esc(get_following($uid)); ?> </a></p> <p id="followers"><a href=" <?php echo make_url("relations", "followers", esc($uname)); ?>"> <strong>Followers</strong><br /><?php echo esc(get_followers($uid)); ?> </a></p> </div>
//呼び出し $user_id = "49650585"; $results = get_lists($user_id); //結果表示 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Message</title> </head>"; var_dump($results); } if (0) { //呼び出し $user_id = "49650585"; $results = get_follows($user_id); //結果表示 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Message</title> </head>"; var_dump($results); } if (0) { //呼び出し $user_id = "49650585"; //$user_id = "9449612"; //あずまん $results = get_followers($user_id); //結果表示 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Message</title> </head>"; var_dump($results); } //呼び出し $screen_name = "tattyamm"; $results = get_sn2id($screen_name); //結果表示 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /> <title>Message</title> </head>"; var_dump($results); //tattyammに対して49650585がもらえると正解
function nb_follow($login) { $tab = get_followers($login); $nbfollow = count($tab); return $nbfollow; }
public function set_followers() { self::$followers = get_followers(self::$user_id); }