課程
/后端開發
/PHP
/PHP微信公眾平臺開發高級篇—網頁授權接口
http_curl($url,'get') 這個方法沒看到?誰有貼一個
2016-10-10
源自:PHP微信公眾平臺開發高級篇—網頁授權接口 2-1
正在回答
function http_curl($url,$type='get',$res='json',$arr=''){
? ? ? ? //1,初始化curl
? ? ? ? $ch = curl_init();
? ? ? ? //2,設置 curl的參數
? ? ? ? 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,關閉
? ? ? ? curl_close($ch);
? ? ? ? if ($res == 'json') {
? ? ? ? ? ? if ( curl_errno($ch) ) {
? ? ? ? ? ? ? ? return curl_error($ch);
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? return json_decode($output,true);
? ? ? ? ? ? }
? ? }
彈吉他的牛兒
qq_心安_3 提問者
舉報
一招獲取微信用戶資料信息,進而實現業務邏輯,完美
1 回答可以不裝ThinkPHP在服務器上嗎?直接敲代碼
1 回答報錯41001
2 回答老師,thinkphp 沒有 http_crul() 這個方法~~~這個方法需要用原生寫么
1 回答為什么會報43003的錯
4 回答報錯 未定義數組索引:code 怎么解決
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-10-14
function http_curl($url,$type='get',$res='json',$arr=''){
? ? ? ? //1,初始化curl
? ? ? ? $ch = curl_init();
? ? ? ? //2,設置 curl的參數
? ? ? ? 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,關閉
? ? ? ? curl_close($ch);
? ? ? ? if ($res == 'json') {
? ? ? ? ? ? if ( curl_errno($ch) ) {
? ? ? ? ? ? ? ? return curl_error($ch);
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? return json_decode($output,true);
? ? ? ? ? ? }
? ? ? ? }
? ? }