예제 #1
0
 /**
  * 文本请求
  */
 private function receiveText($object)
 {
     $keyword = trim($object->Content);
     if (preg_match('/^天气.+/', $keyword)) {
         // 新浪天气
         include __DIR__ . '/weather.php';
         $city = mb_substr($keyword, 2, mb_strlen($keyword) - 2, 'utf-8');
         $content = weather($city);
     } elseif (preg_match('/^百科.+/', $keyword)) {
         // 百度百科
         include __DIR__ . '/baike.php';
         $words = mb_substr($keyword, 2, mb_strlen($keyword), 'utf-8');
         $content = getEncyclopediaInfo($words);
     } elseif (preg_match('/^人品.+/', $keyword)) {
         // 测试人品
         include __DIR__ . '/renpin.php';
         $name = mb_substr($keyword, 2, mb_strlen($keyword), 'utf-8');
         $content = getRenPin($name);
     } else {
         switch ($keyword) {
             case '占卜':
                 // 每日宜忌
                 $url = 'http://api100.duapp.com/almanac/?appkey=trialuser';
                 $content = json_decode(file_get_contents($url), true);
                 break;
             case '笑话':
                 // 随机笑话
                 $url = 'http://api100.duapp.com/joke/?appkey=trialuser';
                 $content = json_decode(file_get_contents($url), true);
                 $content = explode('<a', $content);
                 $content = trim($content[0]);
                 break;
             default:
                 // xiaoi机器人
                 include __DIR__ . '/xiaoi.php';
                 $content = XiaoI($object->FromUserName, $keyword);
                 break;
         }
     }
     if (is_array($content)) {
         if (isset($content[0]['PicUrl'])) {
             $result = $this->transmitNews($object, $content);
         } else {
             if (isset($content['MusicUrl'])) {
                 $result = $this->transmitMusic($object, $content);
             }
         }
     } else {
         $result = $this->transmitText($object, $content);
     }
     return $result;
 }
예제 #2
0
<?php

$location = whereami($from);
$results = weather($location->woeid);
$forecast = $results->channel->item->forecast;
$today = $forecast[0];
$tomorrow = $forecast[1];
$reply = array();
$reply[] = "Current Conditions: " . $today->text . "\nHigh: " . $today->high . ", Low: " . $today->low;
$reply[] = "Tomorrow: " . $tomorrow->text . "\nHigh: " . $tomorrow->high . ", Low: " . $tomorrow->low;
print_sms_reply($reply);
function whereami($location)
{
    $yql = 'select * from geo.places where text="' . $location . '"';
    $result = getResultFromYQL($yql);
    return $result->query->results->place;
}
function weather($woeid)
{
    $yql = 'select * from weather.forecast where woeid=' . $woeid;
    $result = getResultFromYQL($yql);
    return $result->query->results;
}
예제 #3
0
              <!-- <li><a href="#about">About</a></li> -->
              <!-- <li><a href="#contact">Contact</a></li> -->
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container-fluid">
      <div class="row-fluid">
        <div class="span3">
          <div class="well sidebar-nav">
            <ul class="nav nav-list">
              <li class="nav-header">Sidebar</li>
              <li class="active"><a href="#"><?php 
weather("70100");
?>
</a></li>
             
            </ul>
          </div><!--/.well -->
        </div><!--/span-->
        <div class="span9">
          <div class="hero-unit">
            <p>
			<video id="player_a" class="projekktor" poster="player/media/intro.png" title="Video Player">
			
			</video>
			</p>
           
          </div>
예제 #4
0
파일: index.php 프로젝트: soitun/meta
			echo '<ol class="vid_result_main">';
			
			if($search =="images") {
				image_str(array_merge(image($qs,$start+1), image($qs,$start+5),image($qs,$start+9),image($qs,$start+13)));
			} else
			if($search =="videos") {
				video($qs,$page,21);
			} else
			if($search =="news") {
				news($qs,$page,21);
			}
			echo '</ol>';
			pagination('?q='.$qe.'&search='.$search);
			} else
			if($search =="weather") {
 			 weather();
			} else {
			$limit=12;
			$start = ($page-1) * $limit;
			echo '<ol class="img_result_main">';
			image_str(array_merge(image($qs,$start+1), image($qs,$start+5),image($qs,$start+9)));
			echo "</ol>";
			echo'<div class="results_container">';
?>
<script type="text/javascript"> 
  ( function() {
    if (window.CHITIKA === undefined) {
      window.CHITIKA = { 'units' : [] };
    };
    var unit = {
      'fluidH' : 1,
예제 #5
0
function show_weather($area)
{
    $w = weather($area);
    if (!$w) {
        return false;
    }
    ?>
    <!-- weather -->
  	<div class="weather-container">
      <h4><?php 
    echo $area;
    ?>
 5 day Weather Forecast</h4>
      <ul id="weather">
        <li>
          <span>
            <span class="wearher-icon"><img src="http://openweathermap.org/img/w/<?php 
    echo $w->forecast->time[0]->symbol->attributes()->var;
    ?>
.png" /></span><br />
      	    <strong class="temp"><?php 
    echo ceil($w->forecast->time[0]->temperature->attributes()->day);
    ?>
&deg;C</strong><br />
            <small class="meta">
              <strong>Date</strong> Today<br />
              <strong>Min</strong> <?php 
    echo ceil($w->forecast->time[0]->temperature->attributes()->min);
    ?>
&deg;C
              <strong>Max</strong> <?php 
    echo ceil($w->forecast->time[0]->temperature->attributes()->max);
    ?>
&deg;C
            </small>
          </span>
        </li>
        <li>
          <span>
            <span class="wearher-icon"><img src="http://openweathermap.org/img/w/<?php 
    echo $w->forecast->time[1]->symbol->attributes()->var;
    ?>
.png" /></span><br />
      	    <strong class="temp"><?php 
    echo ceil($w->forecast->time[1]->temperature->attributes()->day);
    ?>
&deg;C</strong><br />
            <small class="meta">
              <strong>Date</strong> <?php 
    echo date('l', strtotime($w->forecast->time[1]->attributes()->day));
    ?>
<br />
              <strong>Min</strong> <?php 
    echo ceil($w->forecast->time[1]->temperature->attributes()->min);
    ?>
&deg;C
              <strong>Max</strong> <?php 
    echo ceil($w->forecast->time[1]->temperature->attributes()->max);
    ?>
&deg;C
            </small>
          </span>
        </li>
        <li>
          <span>
            <span class="wearher-icon"><img src="http://openweathermap.org/img/w/<?php 
    echo $w->forecast->time[2]->symbol->attributes()->var;
    ?>
.png" /></span><br />
      	    <strong class="temp"><?php 
    echo ceil($w->forecast->time[2]->temperature->attributes()->day);
    ?>
&deg;C</strong><br />
            <small class="meta">
              <strong>Date</strong> <?php 
    echo date('l', strtotime($w->forecast->time[2]->attributes()->day));
    ?>
<br />            
              <strong>Min</strong> <?php 
    echo ceil($w->forecast->time[2]->temperature->attributes()->min);
    ?>
&deg;C
              <strong>Max</strong> <?php 
    echo ceil($w->forecast->time[2]->temperature->attributes()->max);
    ?>
&deg;C
            </small>
          </span>
        </li>
        <li>
          <span>
            <span class="wearher-icon"><img src="http://openweathermap.org/img/w/<?php 
    echo $w->forecast->time[3]->symbol->attributes()->var;
    ?>
.png" /></span><br />
      	    <strong class="temp"><?php 
    echo ceil($w->forecast->time[3]->temperature->attributes()->day);
    ?>
&deg;C</strong><br />
            <small class="meta">
              <strong>Date</strong> <?php 
    echo date('l', strtotime($w->forecast->time[3]->attributes()->day));
    ?>
<br />            
              <strong>Min</strong> <?php 
    echo ceil($w->forecast->time[3]->temperature->attributes()->min);
    ?>
&deg;C
              <strong>Max</strong> <?php 
    echo ceil($w->forecast->time[3]->temperature->attributes()->max);
    ?>
&deg;C
            </small>
          </span>
        </li>
        <li>
          <span>
            <span class="wearher-icon"><img src="http://openweathermap.org/img/w/<?php 
    echo $w->forecast->time[4]->symbol->attributes()->var;
    ?>
.png" /></span><br />
      	    <strong class="temp"><?php 
    echo ceil($w->forecast->time[4]->temperature->attributes()->day);
    ?>
&deg;C</strong><br />
            <small class="meta">
              <strong>Date</strong> <?php 
    echo date('l', strtotime($w->forecast->time[3]->attributes()->day));
    ?>
<br />            
              <strong>Min</strong> <?php 
    echo ceil($w->forecast->time[4]->temperature->attributes()->min);
    ?>
&deg;C
              <strong>Max</strong> <?php 
    echo ceil($w->forecast->time[4]->temperature->attributes()->max);
    ?>
&deg;C
            </small>	        
          </span>
        </li>
      </ul>
  	</div>
  <?php 
}
<?php

/**
 * ヘッダー
 * 
 */
$weather = weather();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="imagetoolbar" content="no" />
<title><?php 
/*
 * Print the <title> tag based on what is being viewed.
 */
global $page, $paged;
wp_title('|', true, 'right');
// Add the blog name.
bloginfo('name');
// Add the blog description for the home/front page.
$site_description = get_bloginfo('description', 'display');
if ($site_description && (is_home() || is_front_page())) {
    echo " | {$site_description}";
}
// Add a page number if necessary:
if ($paged >= 2 || $page >= 2) {
    echo ' | ' . sprintf('ページ %s', max($paged, $page));
예제 #7
0
 function forecast($id, $layout = ForecastDay::Day4)
 {
     return weather()->forecast($id, $layout);
 }
예제 #8
0
					<h4><?php 
echo $location;
?>
 </h4>
					<img src="<?php 
echo $icon_url;
?>
">
					<h3><?php 
echo $temp_c;
?>
&degC</h3>
				</div>
				<div id="chicago" style="background-position: center; background-image: url(/assets/images/weatherlogo/Chicaco.png); background-size: contain; background-repeat: no-repeat; color: darkorchid;">
					<?php 
$output = weather('4887398');
$location = $output[0];
$temp_c = $output[2];
$icon_url = "http://openweathermap.org/img/w/{$output['1']}.png";
?>
					<h4><?php 
echo $location;
?>
</h4>
					<img src="<?php 
echo $icon_url;
?>
">
					<h3><?php 
echo $temp_c;
?>
예제 #9
0
//天气查询 开始
if ($keywordsectionArray[1] == "天气") {
    //城市代码 数据库(_(:з」∠)_) 装载 开始
    $citycode["北京"] = "101010100";
    $citycode["西安"] = "101110101";
    $citycode["上海"] = "101020100";
    $citycode["重庆"] = "101040100";
    $citycode["广州"] = "101280101";
    //城市代码 数据库(_(:з」∠)_) 装载 结束
    switch ($keywordsectionArray[0]) {
        case "北京":
        case "西安":
        case "上海":
        case "重庆":
        case "广州":
            $contentStr = weather($citycode[$keywordsectionArray[0]]);
            echo $contentStr;
            break;
        default:
            $contentStr = "%>_<%暂时我们只能查北京,西安,上海,重庆,广州的天气哦_(:з」∠)_";
            echo $contentStr;
    }
}
function weather($code = '101110101')
{
    $url = "http://www.weather.com.cn/data/sk/" . $code . ".html";
    //	$url = "http://www.weather.com.cn/data/cityinfo/".$code.".html";
    //$url = "http://m.weather.com.cn/data/".$code.".html";
    $str = file_get_contents($url);
    $aa = json_decode($str, true);
    //print_r($aa);