課程
/后端開發
/PHP
/PHP微信公眾平臺開發高級篇—生成二維碼接口
為啥我跟老師一模一樣的代碼,http_curl返回的是空值?有跟我遇到一樣問題的嗎?
2017-11-27
源自:PHP微信公眾平臺開發高級篇—生成二維碼接口 1-2
正在回答
在定義ch下面加上這一行就好了
curl_setopt($ch,?CURLOPT_SSL_VERIFYPEER,?false);
我也是 哎
l.m
你的json數據都沒有傳進去,http_curl函數都寫錯啦
protected function http_curl($url, $arr = '', $type = 'get', $res = 'json')??? {??????? $ch = curl_init();??????? //設置curl的參數??????? curl_setopt($ch, CURLOPT_URL, $url);??????? curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);??????? if ($type == 'post') {??????????? curl_setopt($ch, CURLOPT_POST, 1);??????????? curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);??????? }??????? //采集??????? $output = curl_exec($ch);??????? if ($res == 'json') {??????????? if ($err = curl_errno($ch)) {??????????????? //要在關閉之前獲得curl_errno??????????????? curl_close($ch);??????????????? //請求失敗,返回錯誤信息??????????????? return $err;??????????? } else {??????????????? //請求成功??????????????? return json_decode($output, true);??????????? }??????? }??? }
怎么我也是返回null
沒有代碼,怎么跟你看啊。
舉報
微信掃描,值得你擁有,本教程主要講解二維碼接口的實現
1 回答二維碼返回問題
1 回答http_curl
2 回答http_curl
1 回答老師好,請問access_token取到后,是不是需要放到session中呢?實現代碼有嗎?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2019-03-28
在定義ch下面加上這一行就好了
2018-11-01
我也是 哎
2018-07-05
l.m
2018-05-28
你的json數據都沒有傳進去,http_curl函數都寫錯啦
protected function http_curl($url, $arr = '', $type = 'get', $res = 'json')
??? {
??????? $ch = curl_init();
??????? //設置curl的參數
??????? curl_setopt($ch, CURLOPT_URL, $url);
??????? curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
??????? if ($type == 'post') {
??????????? curl_setopt($ch, CURLOPT_POST, 1);
??????????? curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
??????? }
??????? //采集
??????? $output = curl_exec($ch);
??????? if ($res == 'json') {
??????????? if ($err = curl_errno($ch)) {
??????????????? //要在關閉之前獲得curl_errno
??????????????? curl_close($ch);
??????????????? //請求失敗,返回錯誤信息
??????????????? return $err;
??????????? } else {
??????????????? //請求成功
??????????????? return json_decode($output, true);
??????????? }
??????? }
??? }
2018-04-17
怎么我也是返回null
2017-12-05
沒有代碼,怎么跟你看啊。