Скрипт автомотического фолловинга для твитера

lena1

クリエイター
LV
0
 
Перед вам скрипт, который автоматически фолловит пользователей по интересам (поиск идет через <a href="http://search.twitter.com/search.json?):" target="_blank">http://search.twitter.com/search.json?):</a>

<!--c1--><div class='codetop'>Код</div><div class='codemain'><!--ec1--><?php&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Set the twitter user

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$user = "&nbsp;&nbsp; ";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$pass = "&nbsp;&nbsp; ";

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Set the term you want to follow (e.g. "soccer")

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$term = "&nbsp;&nbsp; ";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Get already followed

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$userApiUrl = "http://twitter.com/statuses/friends.json";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ch = curl_init($userApiUrl);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$apiresponse = curl_exec($ch);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_close($ch);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$followed = array();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($apiresponse) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$json = json_decode($apiresponse);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($json != null) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach ($json as $u) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$followed[] = $u->name;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$userApiUrl = "http://search.twitter.com/search.json?q=" . $term . "&rpp=100";&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ch = curl_init($userApiUrl);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$apiresponse = curl_exec($ch);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_close($ch);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($apiresponse) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$results = json_decode($apiresponse);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$count = 20;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($results != null) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$resultsArr = $results->results;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (is_array($resultsArr)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach ($resultsArr as $result) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$from_user = $result->from_user;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!in_array($from_user,$followed)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ch = curl_init("http://twitter.com/friendships/create/" . $from_user . ".json");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_POST, 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_POSTFIELDS,"follow=true");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$apiresponse = curl_exec($ch);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($apiresponse) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$response = json_decode($apiresponse);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($response != null) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (property_exists($response,"following")) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($response->following === true) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Now following " . $response->screen_name . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Couldn't follow " . $response->screen_name . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Follow limit exceeded, skipped " . $from_user . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_close($ch);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo "Already following " . $from_user . "\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;?><!--c2--></div><!--ec2-->

Проверил на своём опыте - <a href="http://twitter.com/pronetsru" target="_blank">http://twitter.com/pronetsru</a> - скрипт отлично работает!
 
Сверху