課程
/后端開(kāi)發(fā)
/PHP
/PHP微信公眾平臺(tái)開(kāi)發(fā)高級(jí)篇—網(wǎng)頁(yè)授權(quán)接口
http_curl($url,'get') 這個(gè)方法沒(méi)看到?誰(shuí)有貼一個(gè)
2016-10-10
源自:PHP微信公眾平臺(tái)開(kāi)發(fā)高級(jí)篇—網(wǎng)頁(yè)授權(quán)接口 2-1
正在回答
function http_curl($url,$type='get',$res='json',$arr=''){
? ? ? ? //1,初始化curl
? ? ? ? $ch = curl_init();
? ? ? ? //2,設(shè)置 curl的參數(shù)
? ? ? ? curl_setopt($ch, CURLOPT_URL, $url);
? ? ? ? curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
? ? ? ? if ($type == 'post') {
? ? ? ? ? ? curl_setopt($ch, CURLOPT_POST, $url);
? ? ? ? ? ? curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
? ? ? ? }
? ? ? ? //3,采集
? ? ? ? $output = curl_exec($ch);
? ? ? ? //4,關(guān)閉
? ? ? ? curl_close($ch);
? ? ? ? if ($res == 'json') {
? ? ? ? ? ? if ( curl_errno($ch) ) {
? ? ? ? ? ? ? ? return curl_error($ch);
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? return json_decode($output,true);
? ? ? ? ? ? }
? ? }
彈吉他的牛兒
qq_心安_3 提問(wèn)者
舉報(bào)
一招獲取微信用戶(hù)資料信息,進(jìn)而實(shí)現(xiàn)業(yè)務(wù)邏輯,完美
1 回答可以不裝ThinkPHP在服務(wù)器上嗎?直接敲代碼
1 回答報(bào)錯(cuò)41001
2 回答老師,thinkphp 沒(méi)有 http_crul() 這個(gè)方法~~~這個(gè)方法需要用原生寫(xiě)么
1 回答為什么會(huì)報(bào)43003的錯(cuò)
4 回答報(bào)錯(cuò) 未定義數(shù)組索引:code 怎么解決
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢(xún)優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-10-14
function http_curl($url,$type='get',$res='json',$arr=''){
? ? ? ? //1,初始化curl
? ? ? ? $ch = curl_init();
? ? ? ? //2,設(shè)置 curl的參數(shù)
? ? ? ? curl_setopt($ch, CURLOPT_URL, $url);
? ? ? ? curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
? ? ? ? if ($type == 'post') {
? ? ? ? ? ? curl_setopt($ch, CURLOPT_POST, $url);
? ? ? ? ? ? curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
? ? ? ? }
? ? ? ? //3,采集
? ? ? ? $output = curl_exec($ch);
? ? ? ? //4,關(guān)閉
? ? ? ? curl_close($ch);
? ? ? ? if ($res == 'json') {
? ? ? ? ? ? if ( curl_errno($ch) ) {
? ? ? ? ? ? ? ? return curl_error($ch);
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? return json_decode($output,true);
? ? ? ? ? ? }
? ? ? ? }
? ? }