Skip to content

Commit

Permalink
Edited the README.md file to be compatible with githb
Browse files Browse the repository at this point in the history
  • Loading branch information
aphoe committed Oct 14, 2015
1 parent 1c9d9e9 commit d4abc52
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
23 changes: 22 additions & 1 deletion README.md
@@ -1 +1,22 @@
//Readme
##About
This repository code is a *crude* script to get the **User IDs** of the followers of a twitter user.

This code implements [Twitter API 1.1](https://dev.twitter.com/docs/api/1.1) as such you need to create [an app](https://apps.twitter.com/app/new) from your twitter account.

I have tried to comment my code as much as I can and I have used user-friendly variable names but sometimes... my brain thinks faster than my hands so some things are skipped ;)

##Instructions
1. Download the zipped file and extract to your web server
2. open `follow.php` and do the following
1. Add the username of the user whose follower you want to save
2. Add your **Twitter App** values to lines 12-15
3. Run the script from your web browser
4. The followers will be saved to a file in the `followers` folder in the format `[username]_followers.txt`

##PHP Server info
Just in case the list of followers is quite much, you might have to change the `max_execution_time` config value in your **PHP Config* file ie php.ini to something meaningful.

I used `43200` (12 hours) on my test server.

##Imported libraries
The project uses the [OAuth Library PHP scripts](http://oauth.net). and are available in the `lib` folder
24 changes: 11 additions & 13 deletions follow.php
@@ -1,4 +1,10 @@
<?php
/**
* Gets the User IDs of of the followers of a Twitter user
* @author aphoe <http://www.github.com/aphoe>
* @date Oct 2015
*/

$user = ''; //Screen name/username of the twitter user in question

require_once 'lib/twitteroauth.php';
Expand All @@ -8,6 +14,11 @@
define('ACCESS_TOKEN', '');
define('ACCESS_TOKEN_SECRET', '');

/*
Do not edit beyond this pointer
Except you know what exactly you are doing
*/

$toa = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

//Create/Open file
Expand All @@ -21,12 +32,6 @@
//get the number of a users followers
$user_details = $toa->get('users/show', array('screen_name'=>$user));
$user_data = json_decode($user_details);
/*
echo '<pre>';
print_r($user_data);
echo '</pre>';
exit;
*/

while($cursor != 0){
//Get followers
Expand All @@ -36,12 +41,6 @@
//Convert JSON returned to array
$data = json_decode($followers);

/*
echo '<pre>';
print_r($data);
echo '</pre>';
*/

//write to file
foreach($data->ids as $id){
fwrite($file, $id . "\n");
Expand Down Expand Up @@ -82,6 +81,5 @@
. '</strong> followers of <strong>' . $user . '</strong> ('
. $user_data->name . ') have been downloaded and saved to file at '
. date('jS M, Y - g:i:s A');
#echo '<br>All the followers of <strong>' . $user . '</strong> have been downloaded and saved to file at ' . date('jS M, Y - g:i:s A');


0 comments on commit d4abc52

Please sign in to comment.