Permalink
Browse files

Added a user agent header to the api request. Some other small modifi…

…cations.
  • Loading branch information...
1 parent 67c303b commit a5f6379264e9294b0a6e57ad2afac04ed2846e47 @davgothic committed Jun 7, 2011
Showing with 6 additions and 7 deletions.
  1. +6 −7 dg-tweets.php
View
@@ -4,12 +4,12 @@
Plugin URI: http://davgothic.com/dg-tweets-wordpress-plugin/
Description: A widget that displays your Twitter Tweets
Author: David Hancock
-Version: v0.1
+Version: v1.1
Author URI: http://davgothic.com
*/
class DG_Tweets extends WP_Widget {
-
+
private $dg_defaults;
private $tweets_cache;
@@ -167,6 +167,7 @@ private function dg_get_tweets($username, $tweetcount, $cachelength)
if ( ! file_exists($this->tweets_cache) OR filemtime($this->tweets_cache) < (time() - $cachelength))
{
$curl = curl_init($twitter_api);
+ curl_setopt($curl, CURLOPT_USERAGENT, 'DG-Tweets/1.1 (+http://github.com/davgothic/DG-Tweets)');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($curl);
curl_close ($curl);
@@ -238,16 +239,14 @@ private function dg_relative_time($time)
{
return 'about '. (int) ($delta / 3600).' hours ago';
}
- else if ($delta < (48 * 60 * 60))
- {
- return '1 day ago';
- }
else
{
- return (int) ($delta / 86400).' days ago';
+ return date('j F', $parsed_date);
}
}
}
DG_Tweets::dg_load();
+
+?>

0 comments on commit a5f6379

Please sign in to comment.