關(guān)于php 接口問題(php接口主要也就是運(yùn)用curl,curl函數(shù))
更新時間:2013年07月01日 10:44:08 作者:
本篇文章是對php中的接口問題(php接口主要也就是運(yùn)用curl,curl函數(shù))進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
接口問題
php調(diào)用接口最主要的就是使用curl抓取信息
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //url地址
curl_setopt($ch, CURLOPT_POST, true); //是否post請求
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //post請求傳遞的數(shù)據(jù)
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//設(shè)置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//返回獲取的輸出文本流
$response = curl_exec($ch); //獲取返回的數(shù)據(jù)
curl_close($ch); //關(guān)閉
php調(diào)用接口最主要的就是使用curl抓取信息
復(fù)制代碼 代碼如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //url地址
curl_setopt($ch, CURLOPT_POST, true); //是否post請求
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //post請求傳遞的數(shù)據(jù)
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//設(shè)置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//返回獲取的輸出文本流
$response = curl_exec($ch); //獲取返回的數(shù)據(jù)
curl_close($ch); //關(guān)閉
相關(guān)文章
setcookie中Cannot modify header information-headers already s
本篇對setcookie中Cannot modify header information-headers already sent by錯誤的解決方法進(jìn)行了詳細(xì)的分析介紹。需要的朋友參考下2013-05-05
php+xml結(jié)合Ajax實(shí)現(xiàn)點(diǎn)贊功能完整實(shí)例
這篇文章主要介紹了php+xml結(jié)合Ajax實(shí)現(xiàn)點(diǎn)贊功能的方法,以一個完整實(shí)例形式詳細(xì)分析了XML文件、html頁面以及Ajax結(jié)合php實(shí)現(xiàn)點(diǎn)贊功能的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-01-01
兩種php去除二維數(shù)組的重復(fù)項(xiàng)方法
這篇文章主要介紹了兩種php去除二維數(shù)組的重復(fù)項(xiàng)方法,大家可以進(jìn)行比較看哪一種更適合自己,需要的朋友可以參考下2015-11-11

