	<?php
	//echo "curPage: ".$curPage;
	// use this instagram access token generator http://instagram.pixelunion.net/
	//https://www.tradexpoindonesia.com/?code=16b401baeee94e36b46adb522c0baaef
	//phpinfo();

	$json = file_get_contents($json_link);	
	if (is_localhost()) {
		$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
	} else {
		$obj = json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $json), true);	
	}
	
	//echo 'var dump: <br>';
	//var_dump($obj);
	if (isset($obj['data'])) {
		$counter = 1;
		foreach ($obj['data'] as $post) {
			$pic_text = (isset($post['caption']['text']) ? $post['caption']['text'] : '');
			$pic_link = (isset($post['link']) ? $post['link'] : '');
			$pic_like_count = (isset($post['likes']['count']) ? $post['likes']['count'] : '');
			$pic_comment_count = (isset($post['comments']['count']) ? $post['comments']['count'] : '');
			$pic_src = '';
			if (isset($post['images']['standard_resolution']['url'])) {
				$pic_src = str_replace("http://", "https://", $post['images']['standard_resolution']['url']);
			}
			//$pic_created_time=date("F j, Y", $post['caption']['created_time']);
			//$pic_created_time=date("F j, Y", strtotime($pic_created_time . " +1 days"));
			if (!isset(${"column1$counter"})) ${"column1$counter"} = '';			
			${"column1$counter"} .= "
			<div class='crop1'>
				<a href='{$pic_link}' target='_blank'>
					<img class='img-fluid' src='{$pic_src}' alt='{$pic_text}'>
				</a>
			</div>";						
			//${"column$counter"} .= "
			//<div class='imgSameSize' style='background-image:url(https://www.klikbca.com/images/top_BCA1.jpg;bca15084761d4ab27a0);'></div>
			//";			
			
			if ($counter == 3) $counter = 0;
			$counter++;
		}
		
		echo '
		<div class="col l-col12 m-col12 s-col12">
			<div class="teasers" style="overflow:scroll; height:598px;">
				<div class="col l-col4 m-col4 s-col4">'.$column11.'</div>
				<div class="col l-col4 m-col4 s-col4">'.$column12.'</div>
				<div class="col l-col4 m-col4 s-col4">'.$column13.'</div>
			</div>
		</div>';
		
		/*
		echo '
		<table>
			<tr>
				<td>'.$column1.'</td>
				<td>'.$column2.'</td>
				<td>'.$column3.'</td>
			</tr>
		</table>';
		*/
	}	
	?> 


