• 天气预报api(4208)
    作曲/百科库/2015/04/19 08:43
    http://miai.sinaapp.com/api/do.php?act=weather&city=北京&key=wdkj

    以下是半成品源码:要用请自己修改:
    <?php

    function get($url,$post='')
    {
    $ch=curl\_init($url);
    curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);
    if(isset($post)){
    curl\_setopt($ch,CURLOPT\_POST,1);
    curl\_setopt($ch,CURLOPT\_POSTFIELDS,$post); }
    curl\_setopt($ch,CURLOPT\_TIMEOUT,120);//超时

    $content=curl\_exec($ch);
    curl\_close($ch);
    return $content;
    }

    $city=urlencode($\_GET['city']);
    $f=get("http://f.10086.cn/weather/sch.do?code=".$city."&userId=-1&fr=info&tp=");
    #echo htmlspecialchars($f);
    preg\_match("!【今天】<br/>(.*)【!Usi",$f,$info);
    #print\_r($info);
    echo $today=strip\_tags(str\_replace("<br/>"," ",$info[1]));

    preg\_match("!【明天】<br/>(.*)【后天】!Usi",$f,$info);
    #print\_r($info);
    echo $tomorrow=strip\_tags(str\_replace("<br/>"," ",$info[1]));
操作:该文章你无法操作
【回复列表】
作曲/@Ta/2015/04/19 08:44
去除下划线前的反斜线
页:1
登陆后可以评论小编得文章奥!

返回首页