/ Published in: PHP
Simple PHP script which allows you to specify your twitter log in details and a search term, then automatically follow users who have tweeted that term. Code is released as Open Source, use it as you wish - please leave my URL in the commented section though.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // Twitter Auto-follow Script by Dave Stevens - http://davestevens.co.uk // Set the twitter user $user = ""; $pass = ""; // Set the term you want to follow (e.g. "soccer") $term = ""; // Get already followed $userApiUrl = "http://twitter.com/statuses/friends.json"; if ($apiresponse) { if ($json != null) { foreach ($json as $u) { $followed[] = $u->name; } } } $userApiUrl = "http://search.twitter.com/search.json?q=" . $term . "&rpp=100"; if ($apiresponse) { $count = 20; if ($results != null) { $resultsArr = $results->results; foreach ($resultsArr as $result) { $from_user = $result->from_user; if ($apiresponse) { if ($response != null) { if (property_exists($response,"following")) { if ($response->following === true) { echo "Now following " . $response->screen_name . "\n"; } else { echo "Couldn't follow " . $response->screen_name . "\n"; } } else { echo "Follow limit exceeded, skipped " . $from_user . "\n"; } } } } else { echo "Already following " . $from_user . "\n"; } } } } } ?>