本文整理匯總了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);
}
}