function test_get_following()
    {
        $result = get_following(1);

        $this->assertEquals($result, 1);
    }
Beispiel #2
0
    get_following();
});
dispatch_post('/unfollow', function () {
    $db = option('db_conn');
    $user = get('user');
    $params = get_http_parameters('POST');
    foreach ($params['target'] as $target) {
        if ($target == $user['id']) {
            continue;
        }
        $stmt = $db->prepare('DELETE FROM follow_map WHERE user = :user AND target = :target');
        $stmt->bindValue(':user', $user['id']);
        $stmt->bindValue(':target', $target);
        $stmt->execute();
    }
    get_following();
});
dispatch_get('/timeline', function () {
    $db = option('db_conn');
    $user = get('user');
    $latest_entry = $_GET['latest_entry'];
    if ($latest_entry) {
        $stmt = $db->prepare('SELECT * FROM (SELECT * FROM entries WHERE (user = :user OR publish_level = 2 OR (publish_level = 1 AND user IN (SELECT target FROM follow_map WHERE user = :user))) AND id > :id ORDER BY id LIMIT 30) AS e ORDER BY e.id DESC');
        $stmt->bindValue(':user', $user['id']);
        $stmt->bindValue(':id', $latest_entry);
    } else {
        $stmt = $db->prepare('SELECT * FROM entries WHERE (user = :user OR publish_level = 2 OR (publish_level = 1 AND user IN (SELECT target FROM follow_map WHERE user = :user))) ORDER BY id DESC LIMIT 30');
        $stmt->bindValue(':user', $user['id']);
    }
    $start = time();
    while (time() - $start < constant('TIMEOUT')) {
<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>
#!/usr/bin/env php
<?php 
define('USER_AGENT', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36');
define('API_PREFIX', 'https://api.github.com');
if (!is_cli()) {
    exit('Please run script in CLI mode.');
}
$args = getopt('u:');
if (!isset($args['u'])) {
    exit('Please type username.');
}
$username = $args['u'];
$my_following = get_following($username);
$result = array();
foreach ($my_following as $value) {
    if (!get_check_status($value, $username)) {
        $result[] = $value;
    }
}
print_r($result);
function get_following($username)
{
    $array = array();
    $object = request(API_PREFIX . '/users/' . $username . '/following');
    foreach ($object as $value) {
        if (!isset($value->login)) {
            exit('API rate limit exceeded.Please use another ip.');
        }
        $array[] = $value->login;
    }
    return $array;