get請(qǐng)求是最簡(jiǎn)單的請(qǐng)求,不過(guò)要注意自己的請(qǐng)求是http請(qǐng)求還是https的請(qǐng)求,因?yàn)閔ttps請(qǐng)求時(shí)要關(guān)閉SSL驗(yàn)證,不然驗(yàn)證通不過(guò),沒(méi)有辦法請(qǐng)求到數(shù)據(jù)。
GET請(qǐng)求的參數(shù)
get傳遞參數(shù)和正常請(qǐng)求url傳遞參數(shù)的方式一樣
function get_info($card){ $url ="http://www.sdt.com/api/White/CardInfo?cardNo=".$bank_card; $ch = curl_init(); //設(shè)置選項(xiàng),包括URL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); //執(zhí)行并獲取HTML文檔內(nèi)容 $output = curl_exec($ch); //釋放curl句柄 curl_close($ch); return $output; }
HTTPS請(qǐng)求時(shí)要注意SSL驗(yàn)證
function get_bankcard_info($bank_card){ $url ="https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=".$bank_card."&cardBinCheck=true"; $ch = curl_init(); //設(shè)置選項(xiàng),包括URL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//繞過(guò)ssl驗(yàn)證 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //執(zhí)行并獲取HTML文檔內(nèi)容 $output = curl_exec($ch); //釋放curl句柄 curl_close($ch); return $output; }
以上就是關(guān)于在php中使用curl發(fā)送get請(qǐng)求時(shí)參數(shù)傳遞問(wèn)題的解析的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!
分享題目:php使用curl發(fā)送get請(qǐng)求時(shí)無(wú)法請(qǐng)求數(shù)據(jù)的解決方法-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://chinadenli.net/article48/dsjshp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開(kāi)發(fā)、手機(jī)網(wǎng)站建設(shè)、云服務(wù)器、網(wǎng)站維護(hù)、品牌網(wǎng)站設(shè)計(jì)、軟件開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容