github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

adityavm / general

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 5706a38

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

All my open source scripts — these were for my use, don't judge. — Read more

  cancel

http://adityamukherjee.com/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Get dump of all tweets from user's timeline into text file 
Aditya Mukherjee (author)
Sat Jul 25 23:53:04 -0700 2009
commit  5706a383909837e3be9e8790597a3081df6572a6
tree    85ce278045abcc1d6e2431bc0d2edcb7bb924f9d
parent  0aec00942ce1b7c8e18cc7c212ff64927b989f3e
general / twitterbookmarker.php twitterbookmarker.php
100644 55 lines (43 sloc) 2.236 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?
# wanted to use Python for this, but I'll need to install
# simpleJSON and stuff, so it's just quicker with PHP at this point
header("Content-type:text/plain");
 
$last_count = file_get_contents('lastFetch');
$tweets = json_decode(file_get_contents("http://USERNAME:PASSWORD@twitter.com/statuses/friends_timeline.json?since_id=$last_count&count=50"), true);
if(!isset($tweets[0]))
die('No new tweets');
 
file_put_contents('lastFetch', $tweets[0]['id']); # this script hates me
 
$blacklist_users = array('ibnlive', 'mrinal', 'baxiabhishek', 'arjunghosh', 'ossguy', 'madguy000', 'thinkgeek', 'freddurst', 'hiway');
$blacklist_domains = array('twitpic', 'ow.ly', 'techcrunch', 'last.fm', 'jsmag', 'ibnlive');
$stopwords = explode(',', file_get_contents('stopwords'));
 
foreach($tweets as $tweet):
if(in_array($tweet['user']['screen_name'], $blacklist_users))
continue;
 
$s = $tweet['text'];
$dup = $s; # to generate tags later on
preg_match_all("/(?:http|https)\:\/\/(\S+)/", $s, $match);
if(count($match[0]) != 0): # make the call
 
# first get the URL endpoint
$ch = curl_init($match[0][0]);
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_TIMEOUT => 1,
CURLOPT_NOBODY => 1
));
curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$host = parse_url($url);
$host = str_ireplace(array(".com", ".org", ".net", "www."), "", $host['host']);
 
if(in_array($host, $blacklist_domains))
continue;
 
foreach($stopwords as $word):
$dup = preg_replace("/\b$word\b/i", "", $dup);
endforeach;
 
$dup = preg_replace("/[^\w\s]/", "", preg_replace("/(?:http|https)\:\/\/(\S+)/", "", $dup)); # one line baby!
$tags_string = strtolower(preg_replace(array("/\+{1,}/", "/\+$/"), array('+', ''), implode('+', explode(' ', $dup))));
 
echo $match[0][0] . "\n" . $url . "\n" . $tags_string . "\n\n";
 
$delicious = file_get_contents("https://USERNAME:PASSWORD@api.del.icio.us/v1/posts/add?url=". urlencode($url) ."&description=" . urlencode($s) . "&tags=tweet-mark+" . $tweet['user']['screen_name'] . "+" . $tags_string);
endif;
endforeach;
 
echo file_get_contents('tweetMarksError');
?>
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server