Files

220 lines
7.6 KiB
PHP
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
<?php
#Written by Dhruv Govil.
#Please credit in code or link to my site if used.
#www.dgovil.com
#Necessary Paramaters
date_default_timezone_set('America/Phoenix');
$uname = 'bateworld';
$limit = '11';
if ($_GET['offset'] == ''){
$offset = '0' ;
}
else {
$offset = $_GET['offset'];};
$key = 'Enter Your Key Here. http://www.tumblr.com/oauth/apps' ;
#Get offset from URL
if (!isset($_GET['post'])){
$postID = '' ;
}
else {
$postID = '&id='.$_GET['post'];
$offset = '0' ;
$limit='2';
};
$key = 'z4bjeUiHPQ5WdDYl724RNeXwLO8PGh8ciGfAYHBsofQfSLx46w' ;
#Generate Tumblr URL
$request = 'https://api.tumblr.com/v2/blog/'.$uname.'.tumblr.com/posts/?api_key='.$key.$postID.'&offset='.$offset.'&limit='.$limit ;
?>
<!--<a href="<?php echo $request ?>">Tumlbr URL</a>-->
<div id="tumblr_content" class="span-24" style="position:relative;">
<?php
#Get Tumblr JSON
$ci = curl_init($request);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
$input = curl_exec($ci);
#Puts JSON into Array
$value = json_decode($input,true);
//var_dump($value);exit();
#Check if Tumblr JSON is correct
if ($value['meta']['msg'] == 'OK'){
#Process JSON Array
$posts = $value['response']['posts'];
$pCount = $value['response']['blog']['posts'];
#echo($pCount);
#var_dump($value);
#Create Post Dump
for($i='0';$i<($limit - 1);$i++){
$inf = $posts[$i];
?>
<div class="tumblr_post post-<?php echo $inf['type'] ?>" style="padding-left:13px;padding-top:12px;height:75px;position:relative;">
<?php
#Title
if (array_key_exists('title', $inf)) { ?>
<?php };
#AlbumArt
if (array_key_exists('album_art', $inf)) { ?>
<img src="<?php Echo ($inf['album_art']); ?>">
<?php };
#Track Name
if (array_key_exists('track_name', $inf)) {
// Echo ($inf['track_name']);
};
#Artist
if (array_key_exists('text', $inf)) {
// Echo ($inf['text']);
};
#Album
if (array_key_exists('text', $inf)) {
// Echo ($inf['text']);
};
#Media player
if (array_key_exists('player', $inf)) {
//Echo ($inf['player'][2]['embed_code']);
// echo $inf['video_url'];
// echo $inf['thumbnail_url'];
echo "<a href=\"".$inf['post_url']."\" target=\"_blank\" style=\"position:relative;display:block;height:75px;width:75px;\">
<img src=\"".$inf['thumbnail_url']."\" width=\"75\" height=\"75\" style=\"border:1px solid blue;\" />
<img src=\"/images/video_play.png\" style=\"position:absolute;top:26px;left:31px;width:12px;height:24px;border:none;\" />
</a>";
};
#PlayCount
if (array_key_exists('plays', $inf)) {
// Echo ($inf['plays']);
};
#Photo (largest size)
if (array_key_exists('photos', $inf)) { ?>
<?php //echo count($inf['photos'][0]['alt_sizes']);
for($p=0;$p < count($inf['photos'][0]['alt_sizes']);$p++)
{
if($inf['photos'][0]['alt_sizes'][$p]['width']==75){
?>
<a href="<?php echo ($inf['post_url']) ?>" class="fimage" target="_blank"><img src="<?php echo($inf['photos'][0]['alt_sizes'][$p]['url']); ?>" style="border:1px solid blue;"></a>
<?php }}
};
#Quote
if (array_key_exists('text', $inf)) {
// Echo ($inf['text']);
};
#Quote Source
if (array_key_exists('source', $inf)) {
// Echo ($inf['source']);
};
#Link
if (array_key_exists('url', $inf)) {
// Echo ($inf['url']);
};
#Caption
if (array_key_exists('caption', $inf)) {
// Echo ($inf['caption']);
};
#Description
if (array_key_exists('description', $inf)) {
// Echo ($inf['description']);
};
#Text Body
if (array_key_exists('body', $inf)) {
//Echo '<p>'.($inf['body']).'</p>';
};
?>
</div>
<?php
#Question Asking Name
if (array_key_exists('asking_name', $inf)) {
// Echo ($inf['asking_name']);
};
#Question Asking Url
if (array_key_exists('asking_url', $inf)) {
// Echo ($inf['asking_url']);
};
#Question
if (array_key_exists('question', $inf)) {
// Echo ($inf['question']);
};
#Answer
if (array_key_exists('answer', $inf)) {
// Echo ($inf['answer']);
};
//Echo ($inf['date']);
//echo '<br/><br/><br/><br/>';
//var_dump($inf);
};
#Page turn
} else { ?>
<p>I Apolgise, but Tumblr appears to be offline. Please check back in a bit</p>
<?php };
?>
<div style="clear:both;">&nbsp;</div>
<div style="position:absolute;top:-20px;right:7px;">
<a href="javascript:donothing();" onclick="gettumblr('<?php echo ($offset + $limit) ?>');" id="tumblr_next">
<img src="/images/icons/arrow-left.png" style="margin-right:3px;"/>
</a>
<?php if($offset >= 11){?>
<a href="javascript:donothing();" onclick="gettumblr('<?php echo ($offset - $limit) ?>');" id="tumblr_prev"><img src="/images/icons/arrow-right.png"/></a>
<?php } else { ?>
<img src="/images/icons/blank_14x16.png"/>
<?php }?>
</div>