Page MenuHomeDevCentral

D3615.id.diff
No OneTemporary

D3615.id.diff

diff --git a/microblogging/TwitterAPIExchange.php b/microblogging/TwitterAPIExchange.php
deleted file mode 100644
--- a/microblogging/TwitterAPIExchange.php
+++ /dev/null
@@ -1,262 +0,0 @@
-<?php
-
-/**
- * Twitter-API-PHP : Simple PHP wrapper for the v1.1 API
- *
- * PHP version 5.3.10
- *
- * @category Awesomeness
- * @package Twitter-API-PHP
- * @author James Mallison <me@j7mbo.co.uk>
- * @license MIT License
- * @link http://github.com/j7mbo/twitter-api-php
- */
-class TwitterAPIExchange
-{
- private $oauth_access_token;
- private $oauth_access_token_secret;
- private $consumer_key;
- private $consumer_secret;
- private $postfields;
- private $getfield;
- protected $oauth;
- public $url;
-
- /**
- * Create the API access object. Requires an array of settings::
- * oauth access token, oauth access token secret, consumer key, consumer secret
- * These are all available by creating your own application on dev.twitter.com
- * Requires the cURL library
- *
- * @param array $settings
- */
- public function __construct(array $settings)
- {
- if (!in_array('curl', get_loaded_extensions()))
- {
- throw new Exception('You need to install cURL, see: http://curl.haxx.se/docs/install.html');
- }
-
- if (!isset($settings['oauth_access_token'])
- || !isset($settings['oauth_access_token_secret'])
- || !isset($settings['consumer_key'])
- || !isset($settings['consumer_secret']))
- {
- throw new Exception('Make sure you are passing in the correct parameters');
- }
-
- $this->oauth_access_token = $settings['oauth_access_token'];
- $this->oauth_access_token_secret = $settings['oauth_access_token_secret'];
- $this->consumer_key = $settings['consumer_key'];
- $this->consumer_secret = $settings['consumer_secret'];
- }
-
- /**
- * Set postfields array, example: array('screen_name' => 'J7mbo')
- *
- * @param array $array Array of parameters to send to API
- *
- * @return TwitterAPIExchange Instance of self for method chaining
- */
- public function setPostfields(array $array)
- {
- if (!is_null($this->getGetfield()))
- {
- throw new Exception('You can only choose get OR post fields.');
- }
-
- if (isset($array['status']) && substr($array['status'], 0, 1) === '@')
- {
- $array['status'] = sprintf("\0%s", $array['status']);
- }
-
- $this->postfields = $array;
-
- return $this;
- }
-
- /**
- * Set getfield string, example: '?screen_name=J7mbo'
- *
- * @param string $string Get key and value pairs as string
- *
- * @return \TwitterAPIExchange Instance of self for method chaining
- */
- public function setGetfield($string)
- {
- if (!is_null($this->getPostfields()))
- {
- throw new Exception('You can only choose get OR post fields.');
- }
-
- $search = array('#', ',', '+', ':');
- $replace = array('%23', '%2C', '%2B', '%3A');
- $string = str_replace($search, $replace, $string);
-
- $this->getfield = $string;
-
- return $this;
- }
-
- /**
- * Get getfield string (simple getter)
- *
- * @return string $this->getfields
- */
- public function getGetfield()
- {
- return $this->getfield;
- }
-
- /**
- * Get postfields array (simple getter)
- *
- * @return array $this->postfields
- */
- public function getPostfields()
- {
- return $this->postfields;
- }
-
- /**
- * Build the Oauth object using params set in construct and additionals
- * passed to this method. For v1.1, see: https://dev.twitter.com/docs/api/1.1
- *
- * @param string $url The API url to use. Example: https://api.twitter.com/1.1/search/tweets.json
- * @param string $requestMethod Either POST or GET
- * @return \TwitterAPIExchange Instance of self for method chaining
- */
- public function buildOauth($url, $requestMethod)
- {
- if (!in_array(strtolower($requestMethod), array('post', 'get')))
- {
- throw new Exception('Request method must be either POST or GET');
- }
-
- $consumer_key = $this->consumer_key;
- $consumer_secret = $this->consumer_secret;
- $oauth_access_token = $this->oauth_access_token;
- $oauth_access_token_secret = $this->oauth_access_token_secret;
-
- $oauth = array(
- 'oauth_consumer_key' => $consumer_key,
- 'oauth_nonce' => time(),
- 'oauth_signature_method' => 'HMAC-SHA1',
- 'oauth_token' => $oauth_access_token,
- 'oauth_timestamp' => time(),
- 'oauth_version' => '1.0'
- );
-
- $getfield = $this->getGetfield();
-
- if (!is_null($getfield))
- {
- $getfields = str_replace('?', '', explode('&', $getfield));
- foreach ($getfields as $g)
- {
- $split = explode('=', $g);
- $oauth[$split[0]] = $split[1];
- }
- }
-
- $base_info = $this->buildBaseString($url, $requestMethod, $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;
-
- $this->url = $url;
- $this->oauth = $oauth;
-
- return $this;
- }
-
- /**
- * Perform the actual data retrieval from the API
- *
- * @param boolean $return If true, returns data.
- *
- * @return string json If $return param is true, returns json data.
- */
- public function performRequest($return = true)
- {
- if (!is_bool($return))
- {
- throw new Exception('performRequest parameter must be true or false');
- }
-
- $header = array($this->buildAuthorizationHeader($this->oauth), 'Expect:');
-
- $getfield = $this->getGetfield();
- $postfields = $this->getPostfields();
-
- $options = array(
- CURLOPT_HTTPHEADER => $header,
- CURLOPT_HEADER => false,
- CURLOPT_URL => $this->url,
- CURLOPT_RETURNTRANSFER => true
- );
-
- if (!is_null($postfields))
- {
- $options[CURLOPT_POSTFIELDS] = $postfields;
- }
- else
- {
- if ($getfield !== '')
- {
- $options[CURLOPT_URL] .= $getfield;
- }
- }
-
- $feed = curl_init();
- curl_setopt_array($feed, $options);
- $json = curl_exec($feed);
- curl_close($feed);
-
- if ($return) { return $json; }
- }
-
- /**
- * Private method to generate the base string used by cURL
- *
- * @param string $baseURI
- * @param string $method
- * @param array $params
- *
- * @return string Built base string
- */
- private function buildBaseString($baseURI, $method, $params)
- {
- $return = array();
- ksort($params);
-
- foreach($params as $key=>$value)
- {
- $return[] = "$key=" . $value;
- }
-
- return $method . "&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $return));
- }
-
- /**
- * Private method to generate authorization header used by cURL
- *
- * @param array $oauth Array of oauth data generated by buildOauth()
- *
- * @return string $return Header used by cURL for request
- */
- private function buildAuthorizationHeader($oauth)
- {
- $return = 'Authorization: OAuth ';
- $values = array();
-
- foreach($oauth as $key => $value)
- {
- $values[] = "$key=\"" . rawurlencode($value) . "\"";
- }
-
- $return .= implode(', ', $values);
- return $return;
- }
-
-}
diff --git a/microblogging/_documents.xml b/microblogging/_documents.xml
deleted file mode 100644
--- a/microblogging/_documents.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<documents topic="microblogging">
- <document>
- <article>index</article>
- <title>µblogging tools</title>
- <description>Microblogging tools.</description>
- </document>
- <document>
- <article>twitterpoints</article>
- <title>Twitter Points</title>
- <description>How many 140 characters messages did you write?</description>
- </document>
-</documents>
diff --git a/microblogging/index.php b/microblogging/index.php
deleted file mode 100644
--- a/microblogging/index.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<h2>µblogging tools</h2>
-<ul>
- <li><strong><a href="/microblogging/twitterpoints">TwitterPoints</a></strong> — How many 140-characters messages did you tweet?</li>
-</ul>
diff --git a/microblogging/twitterpoints.php b/microblogging/twitterpoints.php
deleted file mode 100644
--- a/microblogging/twitterpoints.php
+++ /dev/null
@@ -1,79 +0,0 @@
-<form>
-<div class="row collapse">
- <div class="ten mobile-three columns">
- <input type="text" name="username" id="username" value="" placeholder="Enters the Twitter username." />
- </div>
- <div class="two mobile-one columns">
- <input type="submit" class="button expand postfix" value="Count" />
- </div>
-</div>
-</form>
-<?php
-if (isset($_REQUEST['username']) && $_REQUEST['username'] != '') {
- $username = $_REQUEST['username'];
- $errorMessage = '';
-
- if (!preg_match('/^[A-Za-z0-9_]{1,15}$/', $username)) {
- $errorMessage = "$username doesn't seem to be a valid Twitter username.";
- } else {
- require_once('TwitterAPIExchange.php');
-
- $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
- $getfield = '?screen_name=' . urlencode($_REQUEST['username']) . '&include_rts=false&count=200';
- $requestMethod = 'GET';
-
- $twitter = new TwitterAPIExchange($Config['TwitterAPI']);
- $response = $twitter->setGetfield($getfield)
- ->buildOauth($url, $requestMethod)
- ->performRequest();
- $response = json_decode($response);
-
- if (isset($response->errors)) {
- foreach ($response->errors as $error) {
- $errorMessage .= "<p>$error->message</p>";
- }
- } elseif (isset($response->error)) {
- $errorMessage = "<p>$response->error</p>";
- }
- }
-
- if ($errorMessage !== '') {
- echo "<h2>Can't compute stats.</h2>$errorMessage";
- } else {
-
- $stats = [
- 'tweets' => 0,
- 'total_length' => 0,
- 'len_140' => 0
- ];
-
- foreach ($response as $tweet) {
- $len = strlen($tweet->text);
- $stats['tweets']++;
- $stats['total_length'] += $len;
- if ($len == 140) { $stats['len_140']++; }
- }
- $name = $tweet->user->name;
- $avatar = $tweet->user->profile_image_url_https;
- echo '<div style="text-align: center;">';
- echo "<h2>$name</h2>";
- echo '<img src="', $avatar, '" alt="', $name, "'s", ' avatar" />';
- $score = $stats[len_140] . " Twitter Point" . s($stats['len_140']);
- echo "<h3>$score</h3>";
- $s = s($stats['tweets']);
- echo "<h4>Computed from the last $stats[tweets] tweet$s</h4>";
- $avg = $stats['total_length'] / $stats['tweets'];
- $avg_rnd = round($avg);
- $avg = round($avg, 5);
- $s = s($avg);
- echo "<h4 class=\"hide-for-touch\">Average tweet length: <abbr title=\"$avg\">$avg_rnd</abbr> character$s</h4><h4 class=\"show-for-touch\">Average tweet length: $avg character$s</h4>";
-
- //RT
- $url = 'https://twitter.com/intent/tweet?url=' . get_server_url() . '/TP/' . $username . '&text=%23TP ' . $score . '%20%E2%80%94&related=dereckson,weneldur';
- echo '<p>[ <a href="', $url, '" target="_blank"><i class="social foundicon-twitter"> Share score</i></a> ]</p>';
-
- //Info
- echo '<p style="margin-top: 3em;">You got a Twitter Point each time your tweet is exactly 140 characters.<br />Rules: Yours, not the RT. Points expire after a little less than 200 messages.<br />The Twitter Point concept <a href="https://twitter.com/Weneldur/status/380416650899488768">has been created</a> by Ælfgar.</p>';
- echo '</div>';
- echo '<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>';
-}}
diff --git a/themes/RalfFallsIntoFoundation/footer.php b/themes/RalfFallsIntoFoundation/footer.php
--- a/themes/RalfFallsIntoFoundation/footer.php
+++ b/themes/RalfFallsIntoFoundation/footer.php
@@ -19,9 +19,6 @@
<dd><a href="/finger">Finger client</a></dd>
<dd><a href="/finger/thimbl">Thimbl client</a></dd>
- <dt>µblogging</dt>
- <dd><a href="/microblogging/twitterpoints">Twitter Points</a></dd>
-
<dt>Geocaching</dt>
<dd><a href="/geocaching/caesar">Caesar cipher</a></dd>
<dd><a href="/geocaching/string2number">String to number</a></dd>

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 12:01 (20 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2306397
Default Alt Text
D3615.id.diff (12 KB)

Event Timeline