PHP股票介面如何擷取行情

來源:互聯網
上載者:User
本文主要和大家分享PH,P股票介面如何擷取行情,,主要以代碼的方式和大家分享,希望能協助到大家。

貼上 php 擷取行情示列代碼,

注意:滬深股市 、香港股市、 美國股市所返回的result.lists不同

<?phpheader("Content-Type:text/html;charset=UTF-8");function nowapi_call($a_parm){    if(!is_array($a_parm)){        return false;    }    //combinations    $a_parm['format']=empty($a_parm['format'])?'json':$a_parm['format'];    $apiurl=empty($a_parm['apiurl'])?'http://api.k780.com:88/?':$a_parm['apiurl'].'/?';    unset($a_parm['apiurl']);    foreach($a_parm as $k=>$v){        $apiurl.=$k.'='.$v.'&';    }    $apiurl=substr($apiurl,0,-1);    if(!$callapi=file_get_contents($apiurl)){        return false;    }    //format    if($a_parm['format']=='base64'){        $a_cdata=unserialize(base64_decode($callapi));    }elseif($a_parm['format']=='json'){        if(!$a_cdata=json_decode($callapi,true)){            return false;        }    }else{        return false;    }    //array    if($a_cdata['success']!='1'){        echo $a_cdata['msgid'].' '.$a_cdata['msg'];        return false;    }    return $a_cdata['result'];}$nowapi_parm['app']='finance.stock_realtime';$nowapi_parm['symbol']='sh600000';$nowapi_parm['appkey']='10003';$nowapi_parm['sign']='b59bc3ef6191eb9f747dd4e83c99f2a4';$nowapi_parm['format']='json';$result=nowapi_call($nowapi_parm);var_dump($result);print_r($result);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.