Beste Criminalspoint leden,
Ik weet niet hoe ik het moet uitleggen maar.
De usertime/status is niet goed ingestelt ik weet niet hoe ik het moet fixen.
Url: http://www.onlinestereo.nl/twit/twit.php
Download url: http://www.onlinestereo.nl/twit/twit.rar
Ja ik heb het van internet.
PHP
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Twitter Api Tool</title>
<link rel="stylesheet" href="apitool.css" type="text/css" />
</head>
<!--Copy from here-->
<?php
//Settings
$username = 'M4zzy'; // Twitter username
$tweetCount = 10; // The amount of tweets that will be visible.
$cache_file = ''; //Name of the cachefile
$cache_life = '3600'; //Cachelife in seconds
//Do not edit below if you don't know what you're doing, you might mess up everything.
$twitterFeed = 'http://twitter.com/statuses/user_timeline/'.$username.'.json?count='.$tweetCount;
function timeAgo($timestamp){
$timestamp = strtotime($timestamp);
$now = time();
$timediff = floor($now - $timestamp);
switch(true){
case ($timediff < 60):
return $timediff.' seconds ago.';
case($timediff >= 60 && $timediff < 3600):
return floor($timediff/60).' minutes ago.';
case($timediff >= 3600 && $timediff < 7200):
return floor($timediff/3600).' hour ago.';
case($timediff >= 7200 && $timediff < 86400):
return floor($timediff/3600).' hours ago.';
case($timediff >= 86400 && $timediff < 172800):
return floor($timediff/86400).' day ago.';
case($timediff >= 172800 && $timediff < 602800):
return floor($timediff/86400).' days ago.';
case($timediff >= 602800 && $timediff < 1209600):
return floor($timediff/602800).' week ago.';
case($timediff >= 1209600 && $timediff < 31536000):
return floor($timediff/602800).' weeks ago.';
default:
return date('d-m-Y H:i', $timestamp);
}
}
function makeLinksClickable($text){
$text = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" rel=\"external\" target=\"_blank\">\\2</a>", $text);
$text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" rel=\"external\" target=\"_blank\">\\2</a>", $text);
$text = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" rel=\"external\" target=\"_blank\">@\\1</a>", $text);
$text = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" rel=\"external\" target=\"_blank\">#\\1</a>", $text);
return $text;
}
function cache($path, $time){
$cache = filemtime($path);
if (!$cache || (time() - $cache >= $time)){
return false;
}else{
return true;
}
}
function getinfo($location){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function read($filename){
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
return trim($contents);
}
if (file_exists($cache_file) && cache($cache_file, $cache_life)){
$twitter = read($cache_file);
}else{
$twitter = getinfo($twitterFeed);
file_put_contents($cache_file, $twitter);
}
$tweets = json_decode($twitter);
?>
<div id="latesttweet">
<ul>
<?php
foreach ($tweets as $tweet){
echo '<li>', makeLinksClickable($tweet->text), '<br /><span><a href="http://twitter.com/' . $username . '/status/', $tweet->id, '/" rel="external" target="_blank">', timeAgo($tweet->created_at), '</a></span></li>';
}
echo '<span class="more"><a href="http://twitter.com/', $username, '/" rel="external" target="_blank">More...</a></span>';
?>
</ul>
Toon Meer
Met vriendelijke groet,
Freaky-Flow.