本文整理汇总了PHP中Instagram::fetchJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP Instagram::fetchJSON方法的具体用法?PHP Instagram::fetchJSON怎么用?PHP Instagram::fetchJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instagram
的用法示例。
在下文中一共展示了Instagram::fetchJSON方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: glob
function __construct()
{
$list = glob(Instagram::CACHEFOLDER . "*.json");
$oldCount = count($list);
$ignoreList = array();
if (file_exists(".DEV")) {
$oldCount = 0;
}
if (file_exists(".IGNORE")) {
$tmp = trim(file_get_contents(".IGNORE"));
$tmp2 = explode("\n", $tmp);
foreach ($tmp2 as $ignore) {
$ignore = trim($ignore);
if (!empty($ignore)) {
$ignoreList[] = $ignore;
}
}
}
$i = new Instagram();
$i->fetchJSON()->parse($ignoreList);
$rsscontent = file_get_contents("tpl/rss.tpl");
$feeditems = "";
$list = glob(Instagram::CACHEFOLDER . "*.json");
if ($oldCount != count($list)) {
$nodes = array();
foreach ($list as $fn) {
$n = json_decode(file_get_contents($fn));
if (isset($n->code) && isset($n->date)) {
$nodes[] = $n;
}
}
usort($nodes, function ($a, $b) {
return (double) $a->date != (double) $b->date ? (double) $a->date > (double) $b->date ? -1 : 1 : 0;
});
$template = file_get_contents('tpl/front.tpl');
$btemplate = file_get_contents('tpl/block.tpl');
$blocks = "";
foreach ($nodes as $node) {
if (in_array($node->code, $ignoreList)) {
continue;
}
$block = $btemplate;
$block = str_replace("{IMAGE}", "data/" . $node->code . "_320.jpg", $block);
$block = str_replace("{CAPTION}", $node->caption, $block);
$block = str_replace("{CODE}", $node->code, $block);
$block = str_replace("{LIKES}", $node->likes->count, $block);
$block = str_replace("{LIKESSTRING}", $node->likes->count > 0 ? "<span style='color: #FF0000;'>{$node->likes->count} ♥</span> " : "", $block);
$bwidth = 320;
$bheight = 320;
if (!file_exists("data/" . $node->code . "_320.jpg")) {
`/usr/bin/convert -strip -filter Lanczos -interlace Plane -sampling-factor 4:2:0 -define jpeg:dct-method=float -quality 85% -geometry 320x www/data/{$node->code}.jpg www/data/{$node->code}_320.jpg`;
}
list($width, $height, $type, $attr) = getimagesize("www/data/{$node->code}_320.jpg");
$bheight = $height;
$block = str_replace("{WIDTH}", $width, $block);
$block = str_replace("{HEIGHT}", $height, $block);
$blocks .= $block;
$feeditems .= "<item>\n <title>" . $node->code . "</title>\n <link>http://brandtrapselfie.nl/data/" . $node->code . ".jpg</link>\n <description>" . $node->caption . "</description>\n <enclosure url='http://brandtrapselfie.nl/data/" . $node->code . ".jpg' type='image/jpeg' />\n </item>";
}
$template = str_replace('{BLOCKS}', $blocks, $template);
$template = str_replace("{TAGMANAGERS}", file_get_contents(".tagmanagers"), $template);
$rsscontent = str_replace("{FEEDITEMS}", $feeditems, $rsscontent);
file_put_contents('www/index.html', $template);
file_put_contents('www/feed.rss', $rsscontent);
}
}