Esempio n. 1
0
         }
     }
     exit(W::response($xml, $data, 'news'));
     break;
 case 9:
     $res = songshu();
     $data = array(array('title' => '科学松鼠会', 'cover' => $web . '/img/songshu.gif'));
     for ($i = 0; $i < count($data); $i++) {
         if ($res[$i]) {
             array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link']));
         }
     }
     exit(W::response($xml, $data, 'news'));
     break;
 case 10:
     $res = ifanr();
     $data = array(array('title' => '爱范儿 · Beats of Bits', 'cover' => $web . '/img/ifanr.gif'));
     for ($i = 0; $i < count($data); $i++) {
         if ($res[$i]) {
             array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'cover' => $res[$i]['cover'], 'link' => $res[$i]['link']));
         }
     }
     exit(W::response($xml, $data, 'news'));
     break;
 case 11:
     $res = bookrank();
     $data = array(array('title' => '读书排行榜', 'cover' => $web . '/img/meizi/' . mt_rand(0, 9) . '.jpg'));
     for ($i = 0; $i < count($data); $i++) {
         if ($res[$i]) {
             array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link']));
         }
Esempio n. 2
0
<?php

header('Content-type:text/html;charset=utf-8');
function ifanr()
{
    $data = array();
    $url = 'http://www.ifanr.com/feed';
    $result = file_get_contents($url);
    $xml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA);
    for ($i = 0; $i < 6; $i++) {
        $reg = '#(.+)题图来自#i';
        preg_match_all($reg, $xml->channel->item[$i]->description, $matches);
        array_push($data, array('title' => $xml->channel->item[$i]->title, 'description' => $matches[1], 'cover' => $xml->channel->item[$i]->image, 'link' => $xml->channel->item[$i]->link));
    }
    return $data;
}
print_r(ifanr());