116 lines
4.3 KiB
PHP
116 lines
4.3 KiB
PHP
<?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';
|
|
#Get offset from URL
|
|
$key = 'z4bjeUiHPQ5WdDYl724RNeXwLO8PGh8ciGfAYHBsofQfSLx46w' ;
|
|
$limit=4;
|
|
$offset=0;
|
|
#Generate Tumblr URL
|
|
$request = 'https://api.tumblr.com/v2/blog/'.$uname.'.tumblr.com/posts/video/?api_key='.$key.'&limit='.$limit ;
|
|
?>
|
|
|
|
<?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);
|
|
|
|
#Check if Tumblr JSON is correct
|
|
if ($value['meta']['msg'] == 'OK'){
|
|
|
|
#Process JSON Array
|
|
$posts = $value['response']['posts'];
|
|
$pCount = $value['response']['blog']['posts'];
|
|
|
|
|
|
#Create Post Dump
|
|
|
|
for($i='0';$i<($limit - 0);$i++){
|
|
$inf = $posts[$i];
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
if (array_key_exists('player', $inf)) {
|
|
//echo ($inf['player'][0]['embed_code']);
|
|
// echo $inf['video_url'];
|
|
//var_dump($inf);
|
|
|
|
// echo $inf['video_url'];
|
|
//echo $inf['thumbnail_url'];
|
|
//echo $inf['post_url'];
|
|
if(isset($inf['video_url'])){
|
|
echo '<div style="position:relative;"><a class="jackbox" href="/community.php?pdp=101#tumblr" style="margin-left:0px;" data-group="tumblr" data-autoplay="true" data-title="bateworld tumblr feed" data-description="#hp_tumblr_desc"><div class="jackbox-hover jackbox-hover-black jackbox-hover-magnify" style=""></div> <img src="'.$inf['thumbnail_url'].'" style="width:100%;height:auto;margin-bottom:1px;" /></a></div>';
|
|
|
|
echo '<div id="hp_tumblr_desc" style="display:none;">'.$inf['caption'].'</div>';
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
#Page turn
|
|
|
|
} else { ?>
|
|
<p>I Apolgise, but Tumblr appears to be offline. Please check back in a bit</p>
|
|
<?php }; ?>
|
|
|
|
<?php $limit=3;
|
|
$request = 'https://api.tumblr.com/v2/blog/'.$uname.'.tumblr.com/posts/photo/?api_key='.$key.'&offset='.$offset.'&limit='.$limit ;
|
|
#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);
|
|
|
|
#Check if Tumblr JSON is correct
|
|
if ($value['meta']['msg'] == 'OK'){
|
|
|
|
#Process JSON Array
|
|
$posts = $value['response']['posts'];
|
|
$pCount = $value['response']['blog']['posts'];
|
|
|
|
|
|
#Create Post Dump
|
|
|
|
for($i='0';$i<($limit - 0);$i++){
|
|
|
|
$inf = $posts[$i];
|
|
?>
|
|
|
|
<?php
|
|
//var_dump($inf);
|
|
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($p==0){
|
|
if($inf['photos'][0]['alt_sizes'][$p]['width'] < 600){
|
|
?>
|
|
|
|
<div style="position:relative;"><a class="jackbox" href="/community.php?pdp=101#tumblr" style="margin-left:0px;" data-group="tumblr" data-autoplay="true" data-title="bateworld tumblr feed" data-description=""><div class="jackbox-hover jackbox-hover-black jackbox-hover-magnify" style=""></div>
|
|
<img src="<?php echo($inf['photos'][0]['alt_sizes'][$p]['url']); ?>" style="width:100%;height:auto;">
|
|
</a></div>
|
|
|
|
|
|
<?php }}}};}}?>
|