:) これは、Instagram からエントリを取得するために現在使用しているコードです。
<?php
setlocale(LC_TIME, 'it_IT');
function get_instagram($tag=bombacarta,$count=10,$width=612,$height=612){
$url = 'https://api.instagram.com/v1/tags/'.$tag.'/media/recent/?access_token=13137.f59def8.1a759775695548999504c219ce7b2ecf&count='.$count;
// Also Perhaps you should cache the results as the instagram API is slow
$cache = './wp-content/themes/raymond-31/instagram_json/'.sha1($url).'.json';
if(file_exists($cache) && filemtime($cache) > time() - 500){
// If a cache file exists, and it is newer than 1 hour, use it
$jsonData = json_decode(file_get_contents($cache));
} else {
$jsonData = json_decode((file_get_contents($url)));
file_put_contents($cache,json_encode($jsonData));
}
$result = '<div style="border-top:1px solid #ddd">'.PHP_EOL;
foreach ($jsonData->data as $key=>$value) {
$location = (!empty($value->location->name))?'presso '.$value->location->name:null;
$result .= "\t".'<em>'.htmlentities($value->caption->text, ENT_QUOTES, "UTF-8").'</em><br /><img src="'.$value->images->standard_resolution->url.'" alt="'.htmlentities($value->caption->text, ENT_QUOTES, "UTF-8").'" width="'.$width.'" height="'.$height.'" /><br /><div class="postinfo">Scattata da '.$value->caption->from->full_name.' il '.htmlentities(gmstrftime('%e %B %Y alle %R', $value->caption->created_time + 7200)).' '.htmlentities($location).'</div><br />'.PHP_EOL;
}
$result .= '</div>'.PHP_EOL;
return $result;
}
echo get_instagram();
?>
5 つのエントリの後で、他のエントリをサムネイルとして表示できるようにしたいと考えています。だから私は standard_resolution に 5 つのエンティティを持ちたいと思います.. 10..? 20..? (わからない)クリック可能なサムネイルとして。
もちろん、standard_resolution をサムネイル解像度に置き換えて、コードをもう一度コピーして貼り付けることもできますが、エントリ 0 の代わりに (たとえば) エントリ 5 から開始するように指定するにはどうすればよいですか (他の画像の前に同じ 5 つの画像を繰り返すことを避けるため)。 )? :)