diff --git a/README.md b/README.md index e77ebf6..6ba018b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ Offline Greptweet on Chrome IOS * Uses [HTML offline feature](http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html) -* Authentication free, using * Aims to [suck less](http://suckless.org) by keeping lines of code low * Encourage folks to use `fetch-tweets.sh` themselves and get into shell ;) * Dependencies: curl, libhtml-parser-perl (to decode HTML entities), xmlstarlet, coreutils, PHP diff --git a/expand-urls.sh b/expand-urls.sh deleted file mode 100755 index 90ef972..0000000 --- a/expand-urls.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# vim: set ts=4 sw=4 - -test -s "$1" || exit -test "${1##*.}" = 'txt' || exit - -temp=$(mktemp "$1.XXXX") -trap "rm -f $temp" EXIT - -IFS='|' -while read -r id date text -do - url=$(echo $text | grep --only-matching --perl-regexp "http(s?):\/\/[^ \"\(\)\<\>]*") - expandedURL=$(curl "$url" -m5 -s -L -I -o /dev/null -w '%{url_effective}') - t=${text/$url/$expandedURL} - echo "$id|$date|$t" -done < $1 > $temp - -mv $temp $1 diff --git a/oauth.php b/oauth.php new file mode 100644 index 0000000..b47c5fb --- /dev/null +++ b/oauth.php @@ -0,0 +1,59 @@ +$value){ + $r[] = "$key=" . rawurlencode($value); + } + return $method."&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r)); +} + +function buildAuthorizationHeader($oauth) { + $r = 'Authorization: OAuth '; + $values = array(); + foreach($oauth as $key=>$value) + $values[] = "$key=\"" . rawurlencode($value) . "\""; + $r .= implode(', ', $values); + return $r; +} + +$url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; + +// Get $oauth_access_token, $oauth_access_token_secret, $consumer_key, $consumer_secret +include("secret.php"); + +$oauth = array( 'oauth_consumer_key' => $consumer_key, + 'oauth_nonce' => time(), + 'oauth_signature_method' => 'HMAC-SHA1', + 'oauth_token' => $oauth_access_token, + 'oauth_timestamp' => time(), + 'screen_name' => 'kaihendry', + 'count' => 200, + 'max_id' => 292551485714227200, + 'oauth_version' => '1.0'); + +$base_info = buildBaseString($url, 'GET', $oauth); +$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret); +$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true)); +$oauth['oauth_signature'] = $oauth_signature; + +// Make Requests +$header = array(buildAuthorizationHeader($oauth), 'Expect:'); +$options = array( CURLOPT_HTTPHEADER => $header, + //CURLOPT_POSTFIELDS => $postfields, + CURLOPT_HEADER => false, + CURLOPT_URL => $url . '?screen_name=kaihendry&count=200&max_id=292551485714227200', + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => false); + +$feed = curl_init(); +curl_setopt_array($feed, $options); +$json = curl_exec($feed); +curl_close($feed); + +echo $json; +// $twitter_data = json_decode($json); +// print_r ($twitter_data); + +?>