Twitter Oauth Auto Follow

Discussion in 'PHP' started by clickcashdaily, Feb 26, 2012.

  1. #1
    I found this code, the person who posted the code say it works for him... but it doesnt work on my end. Anybody know how to get this working?

    <?php
    require_once 'lib/twitteroauth.php';
     
    define('CONSUMER_KEY', 'your_consumer_key');
    define('CONSUMER_SECRET', 'your_consumer_secret');
    define('ACCESS_TOKEN', 'your_access_token');
    define('ACCESS_TOKEN_SECRET', 'your_access_token_secret');
     
    function autoFollow()
    {
        $toa = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
     
        $followers = $toa->get('followers/ids', array('cursor' => -1));
        $followerIds = array();
        foreach ($followers->ids as $i => $id) {
            $followerIds[] = $id;
            if ($i == 99) break; // Deal with only the latest 100 followers.
        }
     
        $friends = $toa->get('friends/ids', array('cursor' => -1));
        $friendIds = array();
        foreach ($friends->ids as $i => $id) {
            $friendIds[] = $id;
            if ($i == 99) break; // Deal with only the latest 100 friends.
        }
     
        foreach ($followerIds as $id) {
            if (empty($friendIds) or !in_array($id, $friendIds)) {
                $ret = $toa->post('friendships/create', array('user_id' => $id));
            }
        }
    }
     
    autoFollow();
    ?>
    PHP:

    I would gladly paypal $5 to whoever can get this working correctly.

    And I would paypal another $5 to who ever can get this script to auto follow people by keyword, and auto unfollow who doesnt follow me
     
    clickcashdaily, Feb 26, 2012 IP