当前位置: 首页>>代码示例>>PHP>>正文


PHP Feed::cacheExpire方法代码示例

本文整理汇总了PHP中Feed::cacheExpire方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::cacheExpire方法的具体用法?PHP Feed::cacheExpire怎么用?PHP Feed::cacheExpire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Feed的用法示例。


在下文中一共展示了Feed::cacheExpire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
开发者ID:BIGjuevos,项目名称:pi-hud,代码行数:31,代码来源:home.php

示例2: catch

$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"]);
            }
        }
    }
} catch (\Zelenin\Telegram\Bot\NotOkException $e) {
开发者ID:pkihoros,项目名称:bots,代码行数:31,代码来源:index.php


注:本文中的Feed::cacheExpire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。