Twitter Follow脚本已修改

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Twitter Follow脚本已修改相关的知识,希望对你有一定的参考价值。

Modified version of the script created by Dave Stevens, Enables the user to input their credentials on a webpage rather than having to change the actual php script code.

Changes: Changed $user,$pass,$term

This is a modified script, the original can be found here: http://snipplr.com/view/17595/twitter-autofollow-php-script/
  1. <head>
  2. <title>Twitter Follow Script - Jonathon Maguire</title>
  3. </head>
  4. <body>
  5. <center>
  6. <u><h1><i>Twitter Follow Script</i></h1></u>
  7. <style>
  8. div {
  9. border: .2em dotted #900;
  10. }
  11. #border {
  12. border-width: .2em;
  13. border-style: solid;
  14. border-color: red;
  15. }
  16. </style>
  17. <form method="post" action="">
  18. <div id="border">
  19. <p><u>Username:</u></p>
  20. <input type="text" name="username" value="">
  21. <br><p><u>Password:</u></p>
  22. <input type="password" name="password" value="">
  23. <br><p><u>Search Term</u></p>
  24. <input type="text" name="term" value=""><br>
  25. <input type="submit" name="submit" value="submit">
  26. </div>
  27. </center>
  28.  
  29. </body>
  30. </html>
  31. <?php
  32.  
  33. // Twitter Auto-follow Script by Dave Stevens - http://davestevens.co.uk, Modified by Jonathon Maguire, http://www.unknowntruth.net
  34.  
  35. if(isset($_POST['submit']))
  36. {
  37. // Set the twitter user
  38. $user = $_POST['username'];
  39. $pass = $_POST['password'];
  40.  
  41. // Set the term you want to follow (e.g. "soccer")
  42. $term = $_POST['term'];
  43.  
  44. // Get already followed
  45. $userApiUrl = "http://twitter.com/statuses/friends.json";
  46.  
  47. if(isset($_POST['submit']))
  48. $ch = curl_init($userApiUrl);
  49. curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
  50. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  51.  
  52. $apiresponse = curl_exec($ch);
  53.  
  54.  
  55. $followed = array();
  56.  
  57. if ($apiresponse) {
  58. $json = json_decode($apiresponse);
  59. if ($json != null) {
  60. foreach ($json as $u) {
  61. $followed[] = $u->name;
  62. }
  63. }
  64. }
  65.  
  66. $userApiUrl = "http://search.twitter.com/search.json?q=" . $term . "&rpp=100";
  67.  
  68. $ch = curl_init($userApiUrl);
  69. curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
  70. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  71.  
  72. $apiresponse = curl_exec($ch);
  73.  
  74.  
  75. if ($apiresponse) {
  76. $results = json_decode($apiresponse);
  77. $count = 90;
  78.  
  79. if ($results != null) {
  80.  
  81. $resultsArr = $results->results;
  82.  
  83. if (is_array($resultsArr)) {
  84.  
  85. foreach ($resultsArr as $result) {
  86.  
  87. $from_user = $result->from_user;
  88.  
  89. if (!in_array($from_user,$followed)) {
  90.  
  91. $ch = curl_init("http://twitter.com/friendships/create/" . $from_user . ".json");
  92. curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
  93. curl_setopt($ch, CURLOPT_POST, 1);
  94. curl_setopt($ch, CURLOPT_POSTFIELDS,"follow=true");
  95. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  96.  
  97. $apiresponse = curl_exec($ch);
  98.  
  99. if ($apiresponse) {
  100. $response = json_decode($apiresponse);
  101.  
  102. if ($response != null) {
  103. if (property_exists($response,"following")) {
  104. if ($response->following === true) {
  105. echo "Now following " . $response->screen_name . " ";
  106. } else {
  107. echo "Couldn't follow " . $response->screen_name . " ";
  108. }
  109. } else {
  110. echo "Follow limit exceeded, skipped " . $from_user . " ";
  111. }
  112. }
  113.  
  114. }
  115.  
  116. curl_close($ch);
  117.  
  118. } else {
  119. echo "Already following " . $from_user . " ";
  120. }
  121.  
  122. }
  123.  
  124. }
  125.  
  126. }
  127.  
  128.  
  129. }
  130. }
  131.  
  132. ?>

以上是关于Twitter Follow脚本已修改的主要内容,如果未能解决你的问题,请参考以下文章

SVN Commit failed (details follow): Access denied已解决

SVN Commit failed (details follow): Access denied已解决

PHP Twitter跟随脚本修改

Twitter跨浏览器关注按钮

在 Twitter 的关注按钮中隐藏“关注者”一词

来自fabric的Twitter登录在片段中不起作用