本文整理汇总了PHP中Feed::cacheDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::cacheDir方法的具体用法?PHP Feed::cacheDir怎么用?PHP Feed::cacheDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feed
的用法示例。
在下文中一共展示了Feed::cacheDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
// Set your access token
$url = '';
// URL RSS feed
$update = json_decode(file_get_contents('php://input'));
//your app
try {
if ($update->message->text == '/email') {
$response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']);
$response = $client->sendMessage(['chat_id' => $update->message->chat->id, 'text' => "You can send email to : Kasra@madadipouya.com"]);
} else {
if ($update->message->text == '/help') {
$response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']);
$response = $client->sendMessage(['chat_id' => $update->message->chat->id, 'text' => "List of commands :\n /email -> Get email address of the owner \n /latest -> Get latest posts of the blog \n \t\t/help -> Shows list of available commands"]);
} else {
if ($update->message->text == '/latest') {
Feed::$cacheDir = __DIR__ . '/cache';
Feed::$cacheExpire = '5 hours';
$rss = Feed::loadRss($url);
$items = $rss->item;
$lastitem = $items[0];
$lastlink = $lastitem->link;
$lasttitle = $lastitem->title;
$message = $lasttitle . " \n " . $lastlink;
$response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']);
$response = $client->sendMessage(['chat_id' => $update->message->chat->id, 'text' => $message]);
} else {
$response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']);
$response = $client->sendMessage(['chat_id' => $update->message->chat->id, 'text' => "Invalid command, please use /help to get list of available commands"]);
}
}
}
示例2: function
<?php
use Cmfcmf\OpenWeatherMap;
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
$app->get('/', function () use($app) {
$view = [];
// NEWS SLIDE
Feed::$cacheExpire = "30 minutes";
Feed::$cacheDir = "/tmp";
$rss_npr = Feed::loadRss("http://www.npr.org/rss/rss.php?id=1001");
$rss_techmeme = Feed::loadRss("http://www.techmeme.com/feed.xml");
$view['news_npr'] = $rss_npr->item;
$view['news_techmeme'] = $rss_techmeme->item;
// WEATHER SLIDE
$lang = 'en';
$units = 'imperial';
$owm = new OpenWeatherMap(null, new WeatherCache(), 60);
try {
$weather = $owm->getWeather('Milpitas', $units, $lang, "06b7f9678c0512b3b8ca9e94758a9601");
$rawForecast = $owm->getWeatherForecast("Milpitas", $units, $lang, "06b7f9678c0512b3b8ca9e94758a9601", 3);
$forecast = [];
while ($rawForecast->valid()) {
$chunk = $rawForecast->current();
$forecast[] = ['start' => $chunk->time->from->getTimestamp() - 3600 * 8, 'low' => $chunk->temperature->min->getValue(), 'avg' => $chunk->temperature->now->getValue(), 'max' => $chunk->temperature->max->getValue(), 'pressure' => $chunk->pressure->getValue(), 'precipitation' => $chunk->precipitation->getValue(), 'humidity' => $chunk->humidity->getValue(), 'clouds' => $chunk->clouds->getValue()];
$rawForecast->next();
}
$forecastAvg = [];
$forecastLow = [];
$forecastHigh = [];
$forecastPrecip = [];
$fp = 0.5;
示例3: Route
<?php
use Nette\Application\Routers\Route;
// Load libraries
require __DIR__ . '/app/libs/nette.min.php';
require __DIR__ . '/app/libs/feed.class.php';
require __DIR__ . '/app/libs/twitter.class.php';
require __DIR__ . '/app/libs/texy.min.php';
$configurator = new Nette\Config\Configurator();
// Enable Nette Debugger for error visualisation & logging
$configurator->enableDebugger(__DIR__ . '/app/log');
// Configure libraries
Twitter::$cacheDir = Feed::$cacheDir = __DIR__ . '/app/temp/cache';
$configurator->setTempDirectory(__DIR__ . '/app/temp');
// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/app/config.neon');
$container = $configurator->createContainer();
// Setup routes
// http://davidgrudl.com/[cs|en]
$container->router[] = new Route('[<lang (?-i)cs|en>]', function ($presenter, $lang) use($container) {
if (!$lang) {
$lang = $container->httpRequest->detectLanguage(array('en', 'cs')) ?: 'cs';
return $presenter->redirectUrl($lang);
}
// create template
$template = $presenter->createTemplate()->setFile(__DIR__ . '/app/' . $lang . '.latte');
// register template helpers like {$foo|date}
$template->registerHelper('date', function ($date) use($lang) {
if ($lang === 'en') {
return date('F j, Y', (int) $date);
} else {