關(guān)于php 接口問題(php接口主要也就是運用curl,curl函數(shù))
更新時間:2013年07月01日 10:44:08 作者:
本篇文章是對php中的接口問題(php接口主要也就是運用curl,curl函數(shù))進行了詳細(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錯誤的解決方法進行了詳細(xì)的分析介紹。需要的朋友參考下2013-05-05php+xml結(jié)合Ajax實現(xiàn)點贊功能完整實例
這篇文章主要介紹了php+xml結(jié)合Ajax實現(xiàn)點贊功能的方法,以一個完整實例形式詳細(xì)分析了XML文件、html頁面以及Ajax結(jié)合php實現(xiàn)點贊功能的技巧,非常具有實用價值,需要的朋友可以參考下2015-01-01